From 91a17e3f0cbf1d377d3e1a38bcc7a8810ebe23cb Mon Sep 17 00:00:00 2001 From: pagedown Date: Wed, 16 Mar 2022 01:03:33 +0800 Subject: [PATCH] Fall back to use POSIX SHELL environment variable --- shell-integration/ssh/bootstrap.py | 2 +- shell-integration/ssh/bootstrap.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/shell-integration/ssh/bootstrap.py b/shell-integration/ssh/bootstrap.py index 26f456f57..5ec35019d 100644 --- a/shell-integration/ssh/bootstrap.py +++ b/shell-integration/ssh/bootstrap.py @@ -21,7 +21,7 @@ request_data = int('REQUEST_DATA') leading_data = b'' HOME = os.path.expanduser('~') -login_shell = pwd.getpwuid(os.geteuid()).pw_shell or 'sh' +login_shell = pwd.getpwuid(os.geteuid()).pw_shell or os.environ.get('SHELL') or 'sh' def set_echo(fd, on=False): diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index 9aa719a4a..fed6a0f1f 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -232,6 +232,10 @@ using_passwd() { return 1 } +using_shell_env() { + [ -n "$SHELL" ] && login_shell="$SHELL" && login_shell_is_ok +} + execute_with_python() { if detect_python; then exec "$python" "-c" "import os; os.execlp('$login_shell', '-' '$shell_name')" @@ -250,7 +254,7 @@ if [ -n "$KITTY_LOGIN_SHELL" ]; then login_shell="$KITTY_LOGIN_SHELL" unset KITTY_LOGIN_SHELL else - using_getent || using_id || using_python || using_perl || using_passwd || die "Could not detect login shell" + using_getent || using_id || using_python || using_perl || using_passwd || using_shell_env || login_shell="sh" fi shell_name=$(command basename $login_shell) [ -n "$login_cwd" ] && cd "$login_cwd"