mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-01-30 09:48:11 +01:00
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.
This commit is contained in:
parent
7f2211a921
commit
71500c1699
@ -10,10 +10,9 @@
|
|||||||
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
||||||
base="$(basename "$1")"
|
base="$(basename "$1")"
|
||||||
|
|
||||||
if [[ "$base" == .* ]]; then
|
case "$base" in
|
||||||
ls_opt="ls -a"
|
.*) ls_opt="ls -a" ;;
|
||||||
else
|
*) ls_opt="ls" ;;
|
||||||
ls_opt="ls"
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
$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; }'
|
$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; }'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user