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

Re: make aliases work inside the function? (using a preprocessor?)



Marc Chantreux wrote:
>
> I have
>
>     % which €
> 	€ () {
> 	setopt localoptions unset nowarncreateglobal
> 	"$@" }
>     % which l
>         l: aliased to print -l
>     % € l error 
>         €: command not found: l

You could also try using:
  alias €='€ '

This doesn't enable alias expansion inside the function if that is
exactly what you need. But it does work for the example above: the
trailing space in the alias indicates that the next word is treated as
being in command position for alias expansion so l will be expanded
already outside the function.

It's quite common to use this with precommands, for example:
for com in command builtin time nice - nocorrect exec rusage noglob eval nohup;
    alias -- $com="$com "

Oliver



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