From 1bed92bed19e119f0cf59f922d29930359e7f8a2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 20 Mar 2023 07:42:10 +0530 Subject: [PATCH] Cleanup previous PR --- kitty_tests/ssh.py | 3 +-- shell-integration/ssh/bootstrap-utils.sh | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py index 3c6048742..3834b7a9d 100644 --- a/kitty_tests/ssh.py +++ b/kitty_tests/ssh.py @@ -176,8 +176,7 @@ env COLORTERM try: expected_login_shell = pwd.getpwuid(os.geteuid()).pw_shell except KeyError: - with suppress(KeyError): - self.skipTest('Skipping login shell detection as getpwuid() failed to read login shell') + self.skipTest('Skipping login shell detection as getpwuid() failed to read login shell') if os.path.basename(expected_login_shell) == 'nologin': self.skipTest('Skipping login shell detection as login shell is set to nologin') for m in methods: diff --git a/shell-integration/ssh/bootstrap-utils.sh b/shell-integration/ssh/bootstrap-utils.sh index a12845750..be5ced53b 100644 --- a/shell-integration/ssh/bootstrap-utils.sh +++ b/shell-integration/ssh/bootstrap-utils.sh @@ -67,12 +67,12 @@ using_id() { } using_python() { - detect_python && output=$(command "$python" -c "import pwd, os; exec(\"try:print(pwd.getpwuid(os.geteuid()).pw_shell)\nexcept:print(os.environ.get('SHELL')or'/bin/sh')\")") \ + detect_python && output=$(command "$python" -c "import pwd, os; print(pwd.getpwuid(os.geteuid()).pw_shell)" 2>/dev/null) \ && login_shell="$output" && login_shell_is_ok } using_perl() { - detect_perl && output=$(command "$perl" -e 'my $shell = (getpwuid($<))[8]; print $shell') \ + detect_perl && output=$(command "$perl" -e 'my $shell = (getpwuid($<))[8]; print $shell' 2>/dev/null) \ && login_shell="$output" && login_shell_is_ok }