Package: bash
Version: 5.2.21-2
X-Debbugs-CC: bug-b...@gnu.org

Hi,

bash 5.0 and 5.2 do not set $BASH to the right value when bash is used as the login shell:

    $ apt install bash-static
    $ getent passwd $USER | cut -d: -f 7
    /bin/bash

$ su $USER -s /bin/bash-static -c 'echo $BASH; readlink /proc/$$/exe; true'
    /usr/bin/bash-static
    /usr/bin/bash-static

$ su -l $USER -s /bin/bash-static -c 'echo $BASH; readlink /proc/$$/exe; true'
    /bin/bash
    /usr/bin/bash-static

(bash-static is not a link to bash)

Bash also uses the value in /etc/passwd when in login mode, although the documentation says

> BASH   Expands to the full filename used to invoke this instance of bash.

"full filename" could be interpreted both as "an absolute filename" as well as "the canonical absolute path".

    $ su $USER -s /bin/bash -c 'echo $BASH; readlink /proc/$$/exe; true'
    /usr/bin/bash
    /usr/bin/bash

    $ su -l $USER -s /bin/bash -c 'echo $BASH; readlink /proc/$$/exe; true'
    /bin/bash
    /usr/bin/bash

Regards,

--
Gioele Barabucci

Reply via email to