Made more portable by using grep -E

This commit is contained in:
2025-05-04 22:58:17 -04:00
parent b2f208473a
commit e59324a53f
2 changed files with 5 additions and 4 deletions

View File

@ -4,8 +4,9 @@ ls zero bash polyfill
allows you to simulate the --zero option of ls from allows you to simulate the --zero option of ls from
gnu coreutils v9, in earlier versions gnu coreutils v9, in earlier versions
relies on coreutils (ls and tr), and grep with also works with bsdgrep, for usage on bsd and mac
the -P option
relies on coreutils (ls and tr), and grep
simply source ls_zero.bash in your .bashrc, simply source ls_zero.bash in your .bashrc,
place it in /etc/profile.d, or similar place it in /etc/profile.d, or similar

View File

@ -4,7 +4,7 @@ _ls() {
} }
_lsp() { _lsp() {
printf "%s" "$*" | grep -qP '(\s|^)--zero(\s|$)' printf "%s" "$*" | grep -qE '(^| )--zero( |$)'
local zero=$? local zero=$?
local args="$@" local args="$@"
declare -a args=(${args[@]/--zero/}) declare -a args=(${args[@]/--zero/})