Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve install.sh #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,31 @@

set -eu

# Detect the shell from which the script was called
parent=$(ps -o comm $PPID |tail -1)
parent=${parent#-} # remove the leading dash that login shells have
case "$parent" in
# shells supported by `micromamba shell init`
bash|fish|xonsh|zsh)
shell=$parent
;;
*)
# use the login shell (basename of $SHELL) as a fallback
shell=${SHELL##*/}
;;
esac
if [ -n "$INIT_WHICH_SHELL" ]; then
shell=$INIT_WHICH_SHELL
else
# Detect the shell from which the script was called
parent=$(ps -o comm $PPID 2>/dev/null |tail -1)
parent=${parent#-} # remove the leading dash that login shells have
# Check if the parent shell is supported
case "$parent" in
bash|fish|xonsh|zsh)
shell=$parent
;;
*)
# If parent shell is not supported (or there is no parent), check the current shell
parent=$(ps -o comm $$ |tail -1)
case "$current" in
bash|fish|xonsh|zsh)
shell=$current
;;
*)
# If neither parent nor current shell is supported, use the login shell
shell=${SHELL##*/}
;;
esac
esac
fi

# Parsing arguments
if [ -t 0 ] ; then
Expand Down
Loading