Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: PJ Eby Newsgroups: gnu.bash.bug Subject: 'local -' disables alias expansion in scripts Date: Tue, 4 Dec 2018 15:38:52 -0500 Lines: 43 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1543956478 23007 208.118.235.17 (4 Dec 2018 20:47:58 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Gm-Message-State: AA+aEWYPQlQMid1jYyCuLQs9hvUM6e4EiPjd5vx3LzNUZO0V1vPY6zAR AMlsiRqGBbKtZXrq45vWNIB/DbczbqAqw8di8w== X-Google-Smtp-Source: AFSGD/WteRdzOLrWTLWeE1AF9z1+0TAWBExKPYFRIEXkyHxYBQb7/dwyFrg5yC48KCHzvCAa5tBibpK0xD/Tvq0msv0= X-Received: by 2002:aca:6245:: with SMTP id w66mr13806831oib.9.1543955946748; Tue, 04 Dec 2018 12:39:06 -0800 (PST) X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x [fuzzy] X-Received-From: 209.190.5.234 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14892 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 -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS -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 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