From 5e7624107c39b86e993807e21e84d516fe13397e Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 12 Aug 2021 11:16:59 +0200 Subject: [PATCH] Adjust 'qsort.sh'. --- snippets/qsort.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/snippets/qsort.sh b/snippets/qsort.sh index 9db7f7f..0be604e 100755 --- a/snippets/qsort.sh +++ b/snippets/qsort.sh @@ -24,8 +24,39 @@ qsort() { array=(a c b "f f" 3 5) + qsort "${array[@]}" +echo "" +echo "" + +echo " The original array was:" +echo " =======================" +printf " %s\n" "${array[@]}" + +echo "" + +echo " Print sorted array 'qsort_ret' using 'printf'.." +echo " ===============================================" +printf " %s\n" "${qsort_ret[@]}" + +echo "" + +echo " Print sorted array 'qsort_ret'using 'for'-loop.." +echo " ================================================" +# the quotes between '${qsort_ret[@]}' are very important +# +for _val in "${qsort_ret[@]}" ; do + echo " $_val" +done + +echo "" + +echo " Output of command \033[1mdeclare -p qsort_ret\033[m.." +echo " =====================================================" +echo "" + declare -p qsort_ret +echo -e "\n" exit 0