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

Re: noglob does not call alias?



On Mar 13,  1:38pm, Christoph (Stucki) von Stuckrad wrote:
}
} aliases are expanded from the beginning of the LINE,
} not from the command itself, so anything in front
} of 'rm' seems to suppress the alias, like e.g.
} FOO=bar rm 1
} also does.

Umm, no.  What gave you that idea?

torch% alias rm='echo not removing'
torch% FOO=bar rm 1
not removing 1

However, aliases defined without -g are only expanded in the command
position (occupied by "noglob" in the original example) OR when the
word in command position is itself an alias ending in a space.

So the original complaint can be resolved by

torch% alias noglob='noglob '
torch% noglob rm ?
not removing ?

} Why did 'rm *', resulting in 'noglob rm -i *' still execute ???
} 
} I assume, the handling of 'denied' case of 'rm *' ends with
} a still existing parameter to 'rm', and thus runs the command
} instead of ignoring it completely?

That's correct.  The handling for "rm *" actually walks through the
argument list and asks once for every "*" or word ending in "/*" and
if the answer is no, deletes it from the argument list and moves on
to the next one.  So "rm * * *" will prompt you three times.

If arguments remain after that, the rm is executed.

-- 
Barton E. Schaefer



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