help-bash
[Top][All Lists]
Advanced

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

Re: Is $SHELL used by bash in anyway?


From: Jeffrey Walton
Subject: Re: Is $SHELL used by bash in anyway?
Date: Fri, 25 Feb 2022 06:30:10 -0500

On Fri, Feb 25, 2022 at 5:53 AM Peng Yu <pengyu.ut@gmail.com> wrote:
>
> In a script run by corn (on macOS), $SHELL is shown as /bin/sh, $BASH
> is shown as /bin/bash.
>
> Within the script, I run this command. $BASH is changed to
> "/usr/local/bin/bash", but $SHELL remains as /bin/sh.
>
>    LANG=en_US.UTF-8 exec /usr/local/bin/bash -c "source ~/.bashrc;
> some_other_script.sh"
>
> Does bash use the variable $SHELL in any way? Or bash simply leave it
> as is as a regular environment variable without doing anything extra?

I believe the first line (shebang) of some_other_script.sh should be:

    #!/usr/bin/env bash

That will set the interpreter for you.

/usr/bin/env is Posix and portable. It works nearly everywhere. Avoid
hardcoding /bin/bash and friends. It will break on some of the BSDs
because Bash is not located there. Always use /usr/bin/env.

Jeff



reply via email to

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