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

Re: real time alias?



2018-03-15 18:51 GMT+01:00 Ray Andrews <rayandrews@xxxxxxxxxxx>:
> 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 use a function instead of an alias:

With an alias:

$ alias foo="echo first"
$ bar() { foo }
$ bar
first
$ alias foo="echo second"
$ bar
first

With a function:

$ foo() { echo first }
$ bar() { foo }
$ bar
first
$ foo() { echo second }
$ bar
second

Best regards,

-- 
Jérémie



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