Some cleanup

This commit is contained in:
Kovid Goyal 2022-03-05 10:58:42 +05:30
parent f3407959a6
commit 0bd1676978
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 31 additions and 31 deletions

View File

@ -86,7 +86,7 @@ that resolve to a location outside the HOME are not allowed.
''') ''')
opt('shell_integration', 'inherit', long_text=''' opt('shell_integration', 'inherit', long_text='''
Control the shell integration on the remote host. See ref:`shell_integration` Control the shell integration on the remote host. See :ref:`shell_integration`
for details on how this setting works. The special value :code:`inherit` means for details on how this setting works. The special value :code:`inherit` means
use the setting from kitty.conf. This setting is useful for overriding use the setting from kitty.conf. This setting is useful for overriding
integration on a per-host basis.''') integration on a per-host basis.''')

View File

@ -71,9 +71,9 @@ fi
data_started="n" data_started="n"
data_complete="n" data_complete="n"
if [ -z "$HOSTNAME" ]; then if [ -z "$HOSTNAME" ]; then
hostname=$(hostname 2> /dev/null) hostname=$(command hostname 2> /dev/null)
if [ -z "$hostname" ]; then if [ -z "$hostname" ]; then
hostname=$(hostnamectl hostname 2> /dev/null) hostname=$(command hostnamectl hostname 2> /dev/null)
if [ -z "$hostname" ]; then if [ -z "$hostname" ]; then
hostname="_"; hostname="_";
fi fi
@ -84,7 +84,7 @@ fi
# ensure $HOME is set # ensure $HOME is set
if [ -z "$HOME" ]; then HOME=~; fi if [ -z "$HOME" ]; then HOME=~; fi
# ensure $USER is set # ensure $USER is set
if [ -z "$USER" ]; then USER=$(whoami 2> /dev/null); fi if [ -z "$USER" ]; then USER=$(command whoami 2> /dev/null); fi
# ask for the SSH data # ask for the SSH data
data_password="DATA_PASSWORD" data_password="DATA_PASSWORD"
@ -108,7 +108,7 @@ untar_and_read_env() {
# extract the tar file atomically, in the sense that any file from the # extract the tar file atomically, in the sense that any file from the
# tarfile is only put into place after it has been fully written to disk # tarfile is only put into place after it has been fully written to disk
tdir=$(mktemp -d "$HOME/.kitty-ssh-kitten-untar-XXXXXXXXXXXX"); tdir=$(command mktemp -d "$HOME/.kitty-ssh-kitten-untar-XXXXXXXXXXXX");
[ $? = 0 ] || die "Creating temp directory failed"; [ $? = 0 ] || die "Creating temp directory failed";
read_n_bytes_from_tty "$1" | command base64 -d | command tar xjf - --no-same-owner -C "$tdir"; read_n_bytes_from_tty "$1" | command base64 -d | command tar xjf - --no-same-owner -C "$tdir";
data_file="$tdir/data.sh"; data_file="$tdir/data.sh";
@ -189,7 +189,7 @@ detect_python() {
} }
parse_passwd_record() { parse_passwd_record() {
printf "%s" "$(grep -o '[^:]*$')" printf "%s" "$(command grep -o '[^:]*$')"
} }
using_getent() { using_getent() {
@ -218,7 +218,7 @@ using_id() {
using_passwd() { using_passwd() {
if [ -f "/etc/passwd" -a -r "/etc/passwd" ]; then if [ -f "/etc/passwd" -a -r "/etc/passwd" ]; then
output=$(grep "^$USER:" /etc/passwd 2>/dev/null) output=$(command grep "^$USER:" /etc/passwd 2>/dev/null)
if [ $? = 0 ]; then if [ $? = 0 ]; then
login_shell=$(echo $output | parse_passwd_record); login_shell=$(echo $output | parse_passwd_record);
if login_shell_is_ok; then return 0; fi if login_shell_is_ok; then return 0; fi
@ -229,7 +229,7 @@ using_passwd() {
using_python() { using_python() {
if detect_python; then if detect_python; then
output=$($python -c "import pwd, os; print(pwd.getpwuid(os.geteuid()).pw_shell)") output=$(command $python -c "import pwd, os; print(pwd.getpwuid(os.geteuid()).pw_shell)")
if [ $? = 0 ]; then if [ $? = 0 ]; then
login_shell=$output; login_shell=$output;
if login_shell_is_ok; then return 0; fi if login_shell_is_ok; then return 0; fi
@ -321,7 +321,7 @@ case "$KITTY_SHELL_INTEGRATION" in
;; ;;
(*) (*)
# not blank # not blank
q=$(printf "%s" "$KITTY_SHELL_INTEGRATION" | grep '\bno-rc\b') q=$(printf "%s" "$KITTY_SHELL_INTEGRATION" | command grep '\bno-rc\b')
if [ -z "$q" ]; then if [ -z "$q" ]; then
exec_with_shell_integration exec_with_shell_integration
# exec failed, unset # exec failed, unset