bug-bash
[Top][All Lists]
Advanced

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

Re: Bug#1069978: bash: incorrect value of $BASH for login shells


From: Chet Ramey
Subject: Re: Bug#1069978: bash: incorrect value of $BASH for login shells
Date: Sun, 28 Apr 2024 16:50:22 -0400
User-agent: Mozilla Thunderbird

On 4/28/24 3:07 PM, Gioele Barabucci wrote:

    $ su -l $USER -s /bin/bash-static -c 'echo $BASH; readlink /proc/$$/exe; head -1z /proc/$$/cmdline; echo'
     /bin/bash
     /usr/bin/bash-static
     -bash-static

So argv[0] == "-bash-static", which causes $0 to be set to -bash-static
and internally sets shell_name to "bash-static" and login_shell to 1
(which notes that bash was executed with argv[0][0] == '-').

Then when you get to setting $BASH, this code gets executed:

  if ((login_shell == 1) && RELPATH(shell_name))
    {
      if (current_user.shell == 0)
        get_current_user_info ();
      name = savestring (current_user.shell);
    }

which has been the way bash has behaved since the bash-1.x days. Is
this enough of an issue to change behavior that dates back that far?

--
``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/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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