Mi objetivo es ejecutar un script, donde la línea shebang hace que se utilice bash. De alguna manera, al ejecutar bash siempre se ejecuta zsh para mí, a pesar de que instalé bash 5 usando Homebrew y Mac (10.15) viene con bash 3.
Todavía me gustaría que zsh fuera el shell por defecto.
Mi objetivo es ejecutar scripts con bash, y las líneas shebang con bash me dan zsh, como muestra la sintaxis que reconoce el scriptsscriptscripts. El uso de -c
La siguiente es sólo para facilitar la ilustración (en comparación con un archivo con shebang).
Aquí están mis intentos de acceder a bash y al contenido de /etc/shells
$ /usr/local/opt/bash/bin/bash -c "echo $SHELL"
/bin/zsh
$ whereis bash
/bin/bash
$ /bin/bash -c "echo $SHELL"
/bin/zsh
$ /bin/bash -c 'echo $SHELL'
/bin/zsh
$ /usr/local/bin/bash -c "echo $SHELL"
/bin/zsh
$ /usr/local/bin/bash -c 'echo $SHELL'
/bin/zsh
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/usr/local/bin/bash
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
$ /usr/bin/env bash -c "echo $SHELL"
/bin/zsh
$ /bin/bash -c "ps -p $$"
PID TTY TIME CMD
6775 9 ttys011 0:00.31 -zsh
$/usr/local/opt/bash/bin/bash -c "ps -p $$"
PID TTY TIME CMD
69799 ttys001 0:00.38 -zsh
$ /usr/local/bin/bash -c 'ps -p $$'
PID TTY TIME CMD
69985 ttys001 0:00.01 ps -p 69985
$ /bin/bash -c "echo $0"
-zsh
$ /usr/local/opt/bash/bin/bash -c "echo $0"
-zsh
Además, he creado el siguiente archivo y lo he ejecutado directamente
#!/usr/bin/env bash
# With /bin/bash on the shebang we get the same output
ps -p $$
echo $SHELL
echo $0
echo bash $BASH_VERSION
echo zsh $ZSH_VERSION
El resultado es:
$ ./bashtest.sh
PID TTY TIME CMD
70188 ttys000 0:00.00 /bin/bash ./bashtest.sh
/bin/zsh
./bashtest.sh
bash 3.2.57(1)-release
zsh