helpThe GNU Bourne-Again SHell - Support: sr #109605, BASH_ENV is sourced in interactive...


sr #109605: BASH_ENV is sourced in interactive mode too

Submitted by:  None
Submitted on:  Fri 21 Dec 2018 06:26:01 PM UTC  
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Works For Me
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 26 Dec 2018 03:40:26 PM UTC, comment #2: 

I can't reproduce it with bash-4.4 or bash-5.0:

jenna.local(1)$ BASH_ENV=./bash-env ./bash
jenna.local(2)$ exit
jenna.local(1)$ BASH_ENV=./bash-env ./bash -i
jenna.local(2)$ exit
jenna.local(1)$ cat bash-env
echo this is bash-env
jenna.local(1)$ BASH_ENV=./bash-env ./bash /dev/null
this is bash-env

Chet Ramey <chet>
Project Administrator
Sun 23 Dec 2018 12:58:09 PM UTC, comment #1: 

WFM with bash 4.4.12 Cygwin:

$ echo 'echo "BASH_ENV read"' >~/my.bash

$ BASH_ENV=~/my.bash bash -i

Ivan Pozdeev <native_api>
Fri 21 Dec 2018 06:26:01 PM UTC, original submission:  

According to the docs:
       When  bash  is started non-interactively, to run a shell script, for example, it looks
       for the variable BASH_ENV in the environment, expands its value if it  appears  there,
       and  uses  the expanded value as the name of a file to read and execute.  Bash behaves
       as if the following command were executed:
              if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
       but the value of the PATH variable is not used to search for the filename.

However, looks like BASH_ENV gets sourced in interactive mode too:

~ $ cat ~/my.bash
echo "BASH_ENV read"
~ $ BASH_ENV=~/my.bash bash -i



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by native_api (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-26 chet StatusNone => Works For Me

    Back to the top

    Powered by Savane 3.5