From b0d8cd3f5da08702d39ee309adf2fe9b675e436d Mon Sep 17 00:00:00 2001 From: Julien Caillon Date: Mon, 15 Jul 2024 19:38:48 +0200 Subject: [PATCH] :bug: fix lexico order in tests --- tests.d/1005-lib-io/02.listPaths.sh | 50 ++++++++++++----------------- valet.d/lib-interactive | 12 +++++++ valet.d/version | 2 +- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/tests.d/1005-lib-io/02.listPaths.sh b/tests.d/1005-lib-io/02.listPaths.sh index ce0782f..19dd127 100644 --- a/tests.d/1005-lib-io/02.listPaths.sh +++ b/tests.d/1005-lib-io/02.listPaths.sh @@ -8,25 +8,25 @@ function testIo::listPaths() { echo "→ io::listPaths \${PWD}/resources/search" io::listPaths "${PWD}/resources/search" - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listPaths \${PWD}/resources/search" true io::listPaths "${PWD}/resources/search" true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listPaths \${PWD}/resources/search" false true io::listPaths "${PWD}/resources/search" false true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listPaths \${PWD}/resources/search" true true io::listPaths "${PWD}/resources/search" true true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo @@ -34,7 +34,7 @@ function testIo::listPaths() { echo 'fileNamedFile() { if [[ ${1##*/} =~ ^file[[:digit:]]+$ ]]; then return 0; else return 1; fi; }' echo "→ io::listPaths \${PWD}/resources/search" true true fileNamedFile io::listPaths "${PWD}/resources/search" true true fileNamedFile - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo @@ -42,7 +42,7 @@ function testIo::listPaths() { echo 'fileNamedFile() { if [[ ${1##*/} =~ ^file[[:digit:]]+$ ]]; then return 0; else return 1; fi; }' echo "→ io::listPaths \${PWD}/resources/search" true true '' folderNamedHidden io::listPaths "${PWD}/resources/search" true true '' folderNamedHidden - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" test::endTest "Testing io::listPaths" 0 @@ -53,19 +53,19 @@ function testIo::listFiles() { echo "→ io::listFiles \${PWD}/resources/search" io::listFiles "${PWD}/resources/search" - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listFiles \${PWD}/resources/search" true io::listFiles "${PWD}/resources/search" true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listFiles \${PWD}/resources/search" true true io::listFiles "${PWD}/resources/search" true true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo @@ -73,7 +73,7 @@ function testIo::listFiles() { echo 'fileNamedFile() { if [[ ${1##*/} =~ ^file[[:digit:]]+$ ]]; then return 0; else return 1; fi; }' echo "→ io::listFiles \${PWD}/resources/search" true true folderNamedHidden io::listFiles "${PWD}/resources/search" true true folderNamedHidden - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" test::endTest "Testing io::listFiles" 0 @@ -84,19 +84,19 @@ function testIo::listDirectories() { echo "→ io::listDirectories \${PWD}/resources/search" io::listDirectories "${PWD}/resources/search" - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listDirectories \${PWD}/resources/search" true io::listDirectories "${PWD}/resources/search" true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo echo "→ io::listDirectories \${PWD}/resources/search" true true io::listDirectories "${PWD}/resources/search" true true - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" echo @@ -104,31 +104,23 @@ function testIo::listDirectories() { echo 'fileNamedFile() { if [[ ${1##*/} =~ ^file[[:digit:]]+$ ]]; then return 0; else return 1; fi; }' echo "→ io::listDirectories \${PWD}/resources/search" true true folderNamedHidden io::listDirectories "${PWD}/resources/search" true true folderNamedHidden - specialArraySort RETURNED_ARRAY + array::sort RETURNED_ARRAY echo "${RETURNED_ARRAY[*]}" test::endTest "Testing io::listDirectories" 0 } -function specialArraySort() { - local -n array=${1} - local -i i j - local temp - for ((i = 0; i < ${#array[@]}; i++)); do - for ((j = i + 1; j < ${#array[@]}; j++)); do - if [[ ( ${array[i]} != "."* && ${array[j]} == "."* ) || ${array[i]} > ${array[j]} ]]; then - temp="${array[i]}" - array[i]="${array[j]}" - array[j]="${temp}" - fi - done - done -} - function main() { + local original_lc_all=${LC_ALL:-} + # make sure the sort is consistent! + LC_ALL=C testIo::listPaths testIo::listFiles testIo::listDirectories + unset LC_ALL + if [[ -n ${original_lc_all} ]]; then + export LC_ALL=${original_lc_all} + fi } main \ No newline at end of file diff --git a/valet.d/lib-interactive b/valet.d/lib-interactive index d8a87b0..261f1a7 100644 --- a/valet.d/lib-interactive +++ b/valet.d/lib-interactive @@ -719,6 +719,13 @@ function interactive::startProgress() { # shellcheck source=lib-io source io + printf '%s' "${AC__CURSOR_HIDE}" + + # disable echoing when we type something + if command -v stty &>/dev/null; then + stty -echo &>/dev/null || : + fi + io::createTempFile _PROGRESS_BAR_UPDATE_FILE="${RETURNED_VALUE}" _PROGRESS_BAR_RUNNING=true @@ -793,4 +800,9 @@ function interactive::stopProgress() { fi printf "%s" "${AC__ERASE_LINE}${AC__CURSOR_SHOW}" + + # restore the key echoing + if command -v stty &>/dev/null; then + stty echo &>/dev/null || : + fi } diff --git a/valet.d/version b/valet.d/version index d5e98f7..6261a05 100644 --- a/valet.d/version +++ b/valet.d/version @@ -1 +1 @@ -1.3.2 \ No newline at end of file +1.3.1 \ No newline at end of file