How to get shell to self-detect using zsh or bash

前端 未结 8 897
再見小時候
再見小時候 2020-12-08 09:20

I\'ve a question on how to tell which shell the user is using. Suppose a script that if the user is using zsh, then put PATH to his .zshrc and if using bash sho

8条回答
  •  一向
    一向 (楼主)
    2020-12-08 09:40

    An alternative, might not work for all shells.

    for x in $(ps -p $$)
    do
      ans=$x
    done
    echo $ans
    

提交回复
热议问题