Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14893 > unrolled thread

Re: 'local -' disables alias expansion in scripts

Started byChet Ramey <chet.ramey@case.edu>
First post2018-12-05 13:47 -0500
Last post2018-12-05 13:47 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: 'local -' disables alias expansion in scripts Chet Ramey <chet.ramey@case.edu> - 2018-12-05 13:47 -0500

#14893 — Re: 'local -' disables alias expansion in scripts

FromChet Ramey <chet.ramey@case.edu>
Date2018-12-05 13:47 -0500
SubjectRe: 'local -' disables alias expansion in scripts
Message-ID<mailman.5242.1544035676.1284.bug-bash@gnu.org>
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.

Chet

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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web