Initial commit
This commit is contained in:
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
||||
ls zero bash polyfill
|
||||
=====================
|
||||
|
||||
allows you to simulate the --zero option of ls from
|
||||
gnu coreutils v9, in earlier versions
|
||||
|
||||
relies on coreutils (ls and tr), and grep with
|
||||
the -P option
|
||||
20
ls_zero.bash
Normal file
20
ls_zero.bash
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
_ls() {
|
||||
env ls "$@"
|
||||
}
|
||||
|
||||
_lsp() {
|
||||
printf "%s" "$*" | grep -qP '(\s|^)--zero(\s|$)'
|
||||
local zero=$?
|
||||
local args="$@"
|
||||
declare -a args=(${args[@]/--zero/})
|
||||
if test "$zero" -eq 0; then
|
||||
output="$(_ls "${args[@]}")"
|
||||
error=$?
|
||||
printf "%s" "$output" | tr '\n' '\0'
|
||||
return $error
|
||||
fi
|
||||
_ls "${args[@]}"
|
||||
}
|
||||
|
||||
alias ls=_lsp
|
||||
Reference in New Issue
Block a user