From 71500c1699c9c50ba3fdeb951a565a086d727b4c Mon Sep 17 00:00:00 2001 From: Peter MacKenzie-Basaraba Date: Sun, 6 Apr 2025 11:24:15 -0600 Subject: [PATCH] Fix: Replace bashism with POSIX-compliant pattern matching Replaced the bash specific conditional [[ $base" == .* ]] with a case statement. Not sure why my first commit ran on my machine without error. --- .local/bin/rotdir | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.local/bin/rotdir b/.local/bin/rotdir index d3b32440..7f4da4fc 100755 --- a/.local/bin/rotdir +++ b/.local/bin/rotdir @@ -10,10 +10,9 @@ [ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 base="$(basename "$1")" -if [[ "$base" == .* ]]; then - ls_opt="ls -a" -else - ls_opt="ls" -fi +case "$base" in + .*) ls_opt="ls -a" ;; + *) ls_opt="ls" ;; +esac $ls_opt "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'