zsh:ls-show-hidden: Add -- support

All arguments following `--` should be taken as either files or
directories not flags, even if they start with a dash.
This commit is contained in:
2022-09-27 01:24:03 +02:00
parent e5010d76b5
commit 69edbd6f10

View File

@@ -24,14 +24,16 @@ if [[ $OSTYPE =~ darwin ]] && (( $+commands[gls] )); then
LS_COMMAND=gls
fi
builtin local non_existing=0
builtin local non_existing=0 no_flags_from_here=0
builtin local -a dirs files
# Pop files and folders from arguments and put them in the corresponding array,
# keep flags (ls takes flag-arguments behind a '=') and warn when non-existing
# arguments were passed.
for arg in "$@"; do
shift
if [[ ${arg#-} != $arg ]]; then
if [[ $arg = '--' ]] && (( ! no_flags_from_here )); then
no_flags_from_here=1
elif [[ ${arg#-} != $arg ]] && (( ! no_flags_from_here )); then
set -- "$@" "$arg"
elif [[ -d "$arg" ]]; then
dirs+="$arg"