[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'local -' disables alias expansion in scripts

From: Chet Ramey
Subject: Re: 'local -' disables alias expansion in scripts
Date: Wed, 5 Dec 2018 13:47:45 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.3.2

On 12/4/18 3:38 PM, PJ Eby wrote:

> Description:
> After a function using 'local -' is invoked in a script, alias
> expansion is disabled, even if it was previously enabled.
> Repeat-By:
> In a script, use shopt -s expand_aliases, then call a function
> containing 'local -';  After the function returns, expand_aliases is
> disabled.
> Fix:
> The issue appears to be caused by set_posix_mode() in builtins/set.def
> reinitializing posix mode even when its state is unchanged (which
> resets expand_aliases to 0).  Not reinitializing this would be a
> possible workaround, but I suspect it would be better to explicitly
> save the state of expand_aliases, as part of
> get_current_options/set_current_options

It's a little bit more complicated, since expand_aliases is just one of the
options modified by posix mode. Maybe a two-step approach is best: revert
posix mode first, as long as it's changed, then process the rest of the
options. That will catch them all, instead of special-casing expand_aliases.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]