[Top][All Lists]

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

'local -' disables alias expansion in scripts

From: PJ Eby
Subject: 'local -' disables alias expansion in scripts
Date: Tue, 4 Dec 2018 15:38:52 -0500

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include
-DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin'  -O2 -g -pipe -Wall
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-m64 -mtune=generic -Wno-parentheses -Wno-format-security
uname output: Linux wisdom.dirtsimple.org 4.16.7-200.fc27.x86_64 #1
SMP Wed May 2 20:33:31 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu

Bash Version: 4.4
Patch Level: 19
Release Status: release


After a function using 'local -' is invoked in a script, alias
expansion is disabled, even if it was previously enabled.


In a script, use shopt -s expand_aliases, then call a function
containing 'local -';  After the function returns, expand_aliases is


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

reply via email to

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