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-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/sha$
uname output: Linux hostname 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31
14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu
Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
        unalias works weirdly inside an if-then block

Repeat-By:
        By sourcing the code below in an interactive shell

        I can reproduce the bug on vanilla 4.4 version,
        on 4.3.46 (Ubuntu 16.04 default) and
        on 4.2.46 (RHEL 7.1 default)

# Small code snippet to reproduce weird unalias functionality
# Call with "source scriptname" in a fresh *interactive* shell

touch /tmp/a /tmp/b
alias cp='cp -i'

if [[ 1 = 1 ]]; then

    echo -n 'before unalias: '
    alias | grep '^alias cp='
    echo -e "(end of alias output)\n"

    unalias cp
    echo -n 'after unalias: '
    alias | grep '^alias cp='
    echo -e "(end of alias output)\n"

    set -x
    # This one will be interactive, but why?
    cp /tmp/a /tmp/b
fi

# This one won't be interactive
cp /tmp/a /tmp/b
set +x

Reply via email to