SHELL environment variable still points to zsh after using bashdetermine shell in script during runtimeWhat sets the $SHELL environment variable?sharing or synchronizing history between Zsh and BashHow to view datetime stamp for history command in Zsh shellGlobbing fails in zsh, but works in bashCan't open shell after changing default shellSerialize shell variable in bash or zshConfigure tmux to use zshzsh HISTFILE - still read from ~/.zsh_historyA bash/zsh script isn't getting invoked from a terminal in FreeBsd, neither in bash nor in zshhow to put variable in CURL header using shell script?zsh PATH variable not properly set from another environment variable

Enchiridion, 16: Does a stoic moan, or not?

How to avoid typing 'git' at the begining of every Git command

How much web presence should I have?

Why did the World Bank set the global poverty line at $1.90?

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes

Does it make sense to use a wavelet that is equal to a sine of one period?

That's not my X, its Y is too Z

What do you call the action of "describing events as they happen" like sports anchors do?

What is Gilligan's full Name?

Create a cube from identical 3D objects

Why would a home insurer offer a discount based on credit score?

If the pressure inside and outside a balloon balance, then why does air leave when it pops?

What is this object?

Why is it bad to use your whole foot in rock climbing

Can I use 220 V outlets on a 15 ampere breaker and wire it up as 110 V?

Do Veracrypt encrypted volumes have any kind of brute force protection?

Should I list a completely different profession in my technical resume?

What is this wall covering type?

Is there a better way to do partial sums of array items in JavaScript?

How to Convert an Object into Array in magento 2

Mathematica 12 has gotten worse at solving simple equations?

Course development: can I pay someone to make slides for the course?

What's the difference between DHCP and NAT? Are they mutually exclusive?

Was planting UN flag on Moon ever discussed?



SHELL environment variable still points to zsh after using bash


determine shell in script during runtimeWhat sets the $SHELL environment variable?sharing or synchronizing history between Zsh and BashHow to view datetime stamp for history command in Zsh shellGlobbing fails in zsh, but works in bashCan't open shell after changing default shellSerialize shell variable in bash or zshConfigure tmux to use zshzsh HISTFILE - still read from ~/.zsh_historyA bash/zsh script isn't getting invoked from a terminal in FreeBsd, neither in bash nor in zshhow to put variable in CURL header using shell script?zsh PATH variable not properly set from another environment variable






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I am trying to jump between zsh and bash.



By default, I have zsh as my shell, I can know this by typing:



echo $SHELL and I get /bin/zsh



However, I want to open Bash, so I type /bin/bash; I assume I am in bash now, but if I echo $SHELL I still get /bin/zsh



What's wrong, please?










share|improve this question
























  • Linking in for similarity: unix.stackexchange.com/q/71121/117549

    – Jeff Schaller
    Jun 4 at 20:34

















4















I am trying to jump between zsh and bash.



By default, I have zsh as my shell, I can know this by typing:



echo $SHELL and I get /bin/zsh



However, I want to open Bash, so I type /bin/bash; I assume I am in bash now, but if I echo $SHELL I still get /bin/zsh



What's wrong, please?










share|improve this question
























  • Linking in for similarity: unix.stackexchange.com/q/71121/117549

    – Jeff Schaller
    Jun 4 at 20:34













4












4








4








I am trying to jump between zsh and bash.



By default, I have zsh as my shell, I can know this by typing:



echo $SHELL and I get /bin/zsh



However, I want to open Bash, so I type /bin/bash; I assume I am in bash now, but if I echo $SHELL I still get /bin/zsh



What's wrong, please?










share|improve this question
















I am trying to jump between zsh and bash.



By default, I have zsh as my shell, I can know this by typing:



echo $SHELL and I get /bin/zsh



However, I want to open Bash, so I type /bin/bash; I assume I am in bash now, but if I echo $SHELL I still get /bin/zsh



What's wrong, please?







bash shell zsh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Jeff Schaller

46.4k1166151




46.4k1166151










asked Jun 4 at 20:16









Jack ThomsonJack Thomson

695




695












  • Linking in for similarity: unix.stackexchange.com/q/71121/117549

    – Jeff Schaller
    Jun 4 at 20:34

















  • Linking in for similarity: unix.stackexchange.com/q/71121/117549

    – Jeff Schaller
    Jun 4 at 20:34
















Linking in for similarity: unix.stackexchange.com/q/71121/117549

– Jeff Schaller
Jun 4 at 20:34





Linking in for similarity: unix.stackexchange.com/q/71121/117549

– Jeff Schaller
Jun 4 at 20:34










2 Answers
2






active

oldest

votes


















4














SHELL is an environment variable that is passed from bash to zsh when you call zsh. SHELL is not one of the Parameters Set By The Shell in zsh, so its value remains intact.



bash$ SHELL=turtle zsh
zsh$ echo $SHELL
turtle


For indications that you're in a zsh shell, try:



echo $ZSH_NAME
echo $0


The SHELL variable is traditionally set by the login program, "as specified by the password database". (Copied from What sets the $SHELL environment variable?)






share|improve this answer

























  • I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

    – Jeff Schaller
    Jun 4 at 20:31






  • 1





    Also for consideration: ps -ocomm= -p $$

    – Jeff Schaller
    Jun 4 at 20:33











  • thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

    – Jack Thomson
    Jun 4 at 21:29











  • Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

    – Jeff Schaller
    Jun 4 at 22:36



















2














Many shells set a version variable on starting.



bash use BASH_VERSION and zsh use ZSH_VERSION.



Setting both variables to a known value will reliably detect which shell was started:



BASH_VERSION=notbash ZSH_VERSION=notzsh sh -c 'echo "$BASH_VERSION $ZSH_VERSION"'


will print notbash 5.3.1 if sh is zsh or 5.0.2(2)-release notzsh if sh is bash.



Sadly ksh segfaults on using KSH_VERSION with a string value.






share|improve this answer























  • maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

    – Jack Thomson
    Jun 4 at 21:32






  • 1





    The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

    – Isaac
    Jun 4 at 21:34












  • fair point, indeed

    – Jack Thomson
    Jun 4 at 21:38











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f522907%2fshell-environment-variable-still-points-to-zsh-after-using-bash%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














SHELL is an environment variable that is passed from bash to zsh when you call zsh. SHELL is not one of the Parameters Set By The Shell in zsh, so its value remains intact.



bash$ SHELL=turtle zsh
zsh$ echo $SHELL
turtle


For indications that you're in a zsh shell, try:



echo $ZSH_NAME
echo $0


The SHELL variable is traditionally set by the login program, "as specified by the password database". (Copied from What sets the $SHELL environment variable?)






share|improve this answer

























  • I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

    – Jeff Schaller
    Jun 4 at 20:31






  • 1





    Also for consideration: ps -ocomm= -p $$

    – Jeff Schaller
    Jun 4 at 20:33











  • thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

    – Jack Thomson
    Jun 4 at 21:29











  • Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

    – Jeff Schaller
    Jun 4 at 22:36
















4














SHELL is an environment variable that is passed from bash to zsh when you call zsh. SHELL is not one of the Parameters Set By The Shell in zsh, so its value remains intact.



bash$ SHELL=turtle zsh
zsh$ echo $SHELL
turtle


For indications that you're in a zsh shell, try:



echo $ZSH_NAME
echo $0


The SHELL variable is traditionally set by the login program, "as specified by the password database". (Copied from What sets the $SHELL environment variable?)






share|improve this answer

























  • I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

    – Jeff Schaller
    Jun 4 at 20:31






  • 1





    Also for consideration: ps -ocomm= -p $$

    – Jeff Schaller
    Jun 4 at 20:33











  • thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

    – Jack Thomson
    Jun 4 at 21:29











  • Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

    – Jeff Schaller
    Jun 4 at 22:36














4












4








4







SHELL is an environment variable that is passed from bash to zsh when you call zsh. SHELL is not one of the Parameters Set By The Shell in zsh, so its value remains intact.



bash$ SHELL=turtle zsh
zsh$ echo $SHELL
turtle


For indications that you're in a zsh shell, try:



echo $ZSH_NAME
echo $0


The SHELL variable is traditionally set by the login program, "as specified by the password database". (Copied from What sets the $SHELL environment variable?)






share|improve this answer















SHELL is an environment variable that is passed from bash to zsh when you call zsh. SHELL is not one of the Parameters Set By The Shell in zsh, so its value remains intact.



bash$ SHELL=turtle zsh
zsh$ echo $SHELL
turtle


For indications that you're in a zsh shell, try:



echo $ZSH_NAME
echo $0


The SHELL variable is traditionally set by the login program, "as specified by the password database". (Copied from What sets the $SHELL environment variable?)







share|improve this answer














share|improve this answer



share|improve this answer








edited Jun 4 at 22:35

























answered Jun 4 at 20:26









Jeff SchallerJeff Schaller

46.4k1166151




46.4k1166151












  • I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

    – Jeff Schaller
    Jun 4 at 20:31






  • 1





    Also for consideration: ps -ocomm= -p $$

    – Jeff Schaller
    Jun 4 at 20:33











  • thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

    – Jack Thomson
    Jun 4 at 21:29











  • Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

    – Jeff Schaller
    Jun 4 at 22:36


















  • I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

    – Jeff Schaller
    Jun 4 at 20:31






  • 1





    Also for consideration: ps -ocomm= -p $$

    – Jeff Schaller
    Jun 4 at 20:33











  • thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

    – Jack Thomson
    Jun 4 at 21:29











  • Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

    – Jeff Schaller
    Jun 4 at 22:36

















I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

– Jeff Schaller
Jun 4 at 20:31





I'd welcome better indications of a zsh shell; a possible list includes $module_path and $ZSH_VERSION, although in theory other shells could set those.

– Jeff Schaller
Jun 4 at 20:31




1




1





Also for consideration: ps -ocomm= -p $$

– Jeff Schaller
Jun 4 at 20:33





Also for consideration: ps -ocomm= -p $$

– Jeff Schaller
Jun 4 at 20:33













thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

– Jack Thomson
Jun 4 at 21:29





thank you, but how did $SHELL get assigned in the first place? I install zsh just recently

– Jack Thomson
Jun 4 at 21:29













Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

– Jeff Schaller
Jun 4 at 22:36






Great point, @Jack. See the update; your passwd entry likely still points to /bin/bash; you may try (or request the change) to set it to zsh.

– Jeff Schaller
Jun 4 at 22:36














2














Many shells set a version variable on starting.



bash use BASH_VERSION and zsh use ZSH_VERSION.



Setting both variables to a known value will reliably detect which shell was started:



BASH_VERSION=notbash ZSH_VERSION=notzsh sh -c 'echo "$BASH_VERSION $ZSH_VERSION"'


will print notbash 5.3.1 if sh is zsh or 5.0.2(2)-release notzsh if sh is bash.



Sadly ksh segfaults on using KSH_VERSION with a string value.






share|improve this answer























  • maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

    – Jack Thomson
    Jun 4 at 21:32






  • 1





    The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

    – Isaac
    Jun 4 at 21:34












  • fair point, indeed

    – Jack Thomson
    Jun 4 at 21:38















2














Many shells set a version variable on starting.



bash use BASH_VERSION and zsh use ZSH_VERSION.



Setting both variables to a known value will reliably detect which shell was started:



BASH_VERSION=notbash ZSH_VERSION=notzsh sh -c 'echo "$BASH_VERSION $ZSH_VERSION"'


will print notbash 5.3.1 if sh is zsh or 5.0.2(2)-release notzsh if sh is bash.



Sadly ksh segfaults on using KSH_VERSION with a string value.






share|improve this answer























  • maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

    – Jack Thomson
    Jun 4 at 21:32






  • 1





    The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

    – Isaac
    Jun 4 at 21:34












  • fair point, indeed

    – Jack Thomson
    Jun 4 at 21:38













2












2








2







Many shells set a version variable on starting.



bash use BASH_VERSION and zsh use ZSH_VERSION.



Setting both variables to a known value will reliably detect which shell was started:



BASH_VERSION=notbash ZSH_VERSION=notzsh sh -c 'echo "$BASH_VERSION $ZSH_VERSION"'


will print notbash 5.3.1 if sh is zsh or 5.0.2(2)-release notzsh if sh is bash.



Sadly ksh segfaults on using KSH_VERSION with a string value.






share|improve this answer













Many shells set a version variable on starting.



bash use BASH_VERSION and zsh use ZSH_VERSION.



Setting both variables to a known value will reliably detect which shell was started:



BASH_VERSION=notbash ZSH_VERSION=notzsh sh -c 'echo "$BASH_VERSION $ZSH_VERSION"'


will print notbash 5.3.1 if sh is zsh or 5.0.2(2)-release notzsh if sh is bash.



Sadly ksh segfaults on using KSH_VERSION with a string value.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 4 at 21:29









IsaacIsaac

13.1k12159




13.1k12159












  • maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

    – Jack Thomson
    Jun 4 at 21:32






  • 1





    The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

    – Isaac
    Jun 4 at 21:34












  • fair point, indeed

    – Jack Thomson
    Jun 4 at 21:38

















  • maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

    – Jack Thomson
    Jun 4 at 21:32






  • 1





    The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

    – Isaac
    Jun 4 at 21:34












  • fair point, indeed

    – Jack Thomson
    Jun 4 at 21:38
















maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

– Jack Thomson
Jun 4 at 21:32





maybe echo $0 is a bit easier than ZSH_VERSION, BASH_VERSION. but I like the idea, didn't about those variables

– Jack Thomson
Jun 4 at 21:32




1




1





The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

– Isaac
Jun 4 at 21:34






The value of $0 could be modified at will, for example: sh -c 'echo "$0"' MyNameOfShell and by several other methods. @JackThomson

– Isaac
Jun 4 at 21:34














fair point, indeed

– Jack Thomson
Jun 4 at 21:38





fair point, indeed

– Jack Thomson
Jun 4 at 21:38

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f522907%2fshell-environment-variable-still-points-to-zsh-after-using-bash%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림