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:
@@ -24,14 +24,16 @@ if [[ $OSTYPE =~ darwin ]] && (( $+commands[gls] )); then
|
|||||||
LS_COMMAND=gls
|
LS_COMMAND=gls
|
||||||
fi
|
fi
|
||||||
|
|
||||||
builtin local non_existing=0
|
builtin local non_existing=0 no_flags_from_here=0
|
||||||
builtin local -a dirs files
|
builtin local -a dirs files
|
||||||
# Pop files and folders from arguments and put them in the corresponding array,
|
# 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
|
# keep flags (ls takes flag-arguments behind a '=') and warn when non-existing
|
||||||
# arguments were passed.
|
# arguments were passed.
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
shift
|
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"
|
set -- "$@" "$arg"
|
||||||
elif [[ -d "$arg" ]]; then
|
elif [[ -d "$arg" ]]; then
|
||||||
dirs+="$arg"
|
dirs+="$arg"
|
||||||
|
|||||||
Reference in New Issue
Block a user