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

Re: real time alias?



2018-03-15 10:51:47 -0700, Ray Andrews:
> If a function calls an alias, if the alias changes, the function must be
> resourced, yes?  That makes nothing but sense sincethe alias is what it is
> at sourcing.  An executed script uses the alias in 'real time'.  But, is
> there a way to make a function also use the real time value of an alias?
[...]

You can always use eval:

   $ f() { eval 'myalias 1'; echo done; }
   $ alias myalias=echo; f
   1
   done
   $ alias myalias=return; f
   $ echo $?
   1

-- 
Stephane



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