Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ls *.mp4 → ls : invalid option -- 'M'



On Sun, Oct 15, 2023 at 5:46 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> It would be pretty easy to add a setopt that would prefix any glob
> result that begins with '-' or Dash with "./".

Or with some inaccuracy if there are files named the same as valid
options to "ls", something like this:

ls () {
  emulate -L zsh
  local i
  for i in {1..$#}
  do
    [[ ${(P)i} = -* && -f ${(P)i} ]] && : ${(P)i::=./${(P)i}}
  done
  command ls $*
}

Or in the current dev build with named references:

ls () {
  emulate -L zsh
  local -n f
  for f in {1..$#}
  do
    [[ $f = -* && -f $f ]] && f=./$f
  done
  command ls $*
}




Messages sorted by: Reverse Date, Date, Thread, Author