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

Re: Bug in function in function



On Fri, 2022-05-20 at 18:25 +0100, Klaus Ethgen wrote:
> Am Fr den 20. Mai 2022 um 18:16 schrieb Mikael Magnusson:
> > On 5/20/22, Klaus Ethgen <Klaus@xxxxxxxxx> wrote:
> > > I have an alias `alias ls="LC_COLLATE=POSIX ls $_ls_opts"` before this
> > > line but that should not interfere the function definition.
> > 
> > In fact it should, and it does. Change your function definition(s) to
> > the form "function ls".
> 
> Putting a `function` in front of `ls()` work.
> 
> However, I was thinking, `function` (in that context) is deprecated.

No, it's valid syntax and will remain so --- just avoid using both
function in front AND () afterwards.  This is indeed the recommended fix
for this case.  The point, in case it isn't already obvious, is that
alias expands everything in command position before it's even been
parsed --- so your "ls" has turned into something else on input before
the shell has even swallowed the ().  With the function keyword, the
following word is no longer in command position.

pws





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