Remove trailing semicolons

This commit is contained in:
pagedown 2022-03-07 11:25:22 +08:00
parent df9e893cbe
commit 3095e7a256
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -81,7 +81,7 @@ if [ -z "$HOSTNAME" ]; then
if [ -z "$hostname" ]; then if [ -z "$hostname" ]; then
hostname=$(command hostnamectl hostname 2> /dev/null) hostname=$(command hostnamectl hostname 2> /dev/null)
if [ -z "$hostname" ]; then if [ -z "$hostname" ]; then
hostname="_"; hostname="_"
fi fi
fi fi
else else
@ -100,12 +100,12 @@ init_tty && trap 'cleanup_on_bootstrap_exit' EXIT
record_separator=$(printf "\036") record_separator=$(printf "\036")
mv_files_and_dirs() { mv_files_and_dirs() {
cwd="$PWD"; cwd="$PWD"
cd "$1"; cd "$1"
command find . -type d -exec mkdir -p "$2/{}" ";" command find . -type d -exec mkdir -p "$2/{}" ";"
command find . -type l -exec sh -c "tgt=\$(command readlink -n \"{}\"); command ln -sf \"\$tgt\" \"$2/{}\"; command rm -f \"{}\"" ";" command find . -type l -exec sh -c "tgt=\$(command readlink -n \"{}\"); command ln -sf \"\$tgt\" \"$2/{}\"; command rm -f \"{}\"" ";"
command find . -type f -exec mv "{}" "$2/{}" ";" command find . -type f -exec mv "{}" "$2/{}" ";"
cd "$cwd"; cd "$cwd"
} }
compile_terminfo() { compile_terminfo() {
@ -130,18 +130,18 @@ 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=$(command 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"
[ -f "$data_file" ] && . "$data_file"; [ -f "$data_file" ] && . "$data_file"
data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR" data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR"
compile_terminfo "$tdir/home" compile_terminfo "$tdir/home"
mv_files_and_dirs "$tdir/home" "$HOME" mv_files_and_dirs "$tdir/home" "$HOME"
[ -e "$tdir/root" ] && mv_files_and_dirs "$tdir/root" "" [ -e "$tdir/root" ] && mv_files_and_dirs "$tdir/root" ""
command rm -rf "$tdir"; command rm -rf "$tdir"
[ -z "KITTY_SSH_KITTEN_DATA_DIR" ] && die "Failed to read SSH data from tty"; [ -z "KITTY_SSH_KITTEN_DATA_DIR" ] && die "Failed to read SSH data from tty"
unset KITTY_SSH_KITTEN_DATA_DIR; unset KITTY_SSH_KITTEN_DATA_DIR
} }
read_record() { read_record() {
@ -175,17 +175,15 @@ if [ "$tty_ok" = "y" ]; then
printf "\r\033[K" > /dev/tty printf "\r\033[K" > /dev/tty
fi fi
shell_integration_dir="$data_dir/shell-integration" shell_integration_dir="$data_dir/shell-integration"
[ -f "$HOME/.terminfo/kitty.terminfo" ] || die "Incomplete extraction of ssh data"; [ -f "$HOME/.terminfo/kitty.terminfo" ] || die "Incomplete extraction of ssh data"
fi fi
login_shell_is_ok() { login_shell_is_ok() {
if [ -z "$login_shell" -o ! -x "$login_shell" ]; then return 1; fi if [ -z "$login_shell" -o ! -x "$login_shell" ]; then return 1; fi
case "$login_shell" in case "$login_shell" in
*sh) return 0; *sh) return 0;
esac esac
return 1; return 1
} }
detect_python() { detect_python() {
@ -193,7 +191,7 @@ detect_python() {
if [ -z "$python" ]; then python=$(command -v python2); fi if [ -z "$python" ]; then python=$(command -v python2); fi
if [ -z "$python" ]; then python=$(command -v python); fi if [ -z "$python" ]; then python=$(command -v python); fi
if [ -z "$python" -o ! -x "$python" ]; then return 1; fi if [ -z "$python" -o ! -x "$python" ]; then return 1; fi
return 0; return 0
} }
parse_passwd_record() { parse_passwd_record() {
@ -205,11 +203,11 @@ using_getent() {
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
output=$(command $cmd passwd $USER 2>/dev/null) output=$(command $cmd passwd $USER 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
fi fi
fi fi
return 1; return 1
} }
using_id() { using_id() {
@ -217,29 +215,29 @@ using_id() {
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
output=$(command $cmd -P $USER 2>/dev/null) output=$(command $cmd -P $USER 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
fi fi
fi fi
return 1; return 1
} }
using_passwd() { using_passwd() {
if [ -f "/etc/passwd" -a -r "/etc/passwd" ]; then if [ -f "/etc/passwd" -a -r "/etc/passwd" ]; then
output=$(command 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
fi fi
fi fi
return 1; return 1
} }
using_python() { using_python() {
if detect_python; then if detect_python; then
output=$(command $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
fi fi
fi fi
@ -250,14 +248,14 @@ execute_with_python() {
if detect_python; then if detect_python; then
exec $python -c "import os; os.execlp('$login_shell', '-' '$shell_name')" exec $python -c "import os; os.execlp('$login_shell', '-' '$shell_name')"
fi fi
return 1; return 1
} }
if [ -n "$KITTY_LOGIN_SHELL" ]; then if [ -n "$KITTY_LOGIN_SHELL" ]; then
login_shell="$KITTY_LOGIN_SHELL" login_shell="$KITTY_LOGIN_SHELL"
unset KITTY_LOGIN_SHELL unset KITTY_LOGIN_SHELL
else else
using_getent || using_id || using_python || using_passwd || die "Could not detect login shell"; using_getent || using_id || using_python || using_passwd || die "Could not detect login shell"
fi fi
shell_name=$(command basename $login_shell) shell_name=$(command basename $login_shell)
@ -272,7 +270,6 @@ if [ "$tty_ok" = "n" ]; then
fi fi
fi fi
exec_bash_with_integration() { exec_bash_with_integration() {
export ENV="$shell_integration_dir/bash/kitty.bash" export ENV="$shell_integration_dir/bash/kitty.bash"
export KITTY_BASH_INJECT="1" export KITTY_BASH_INJECT="1"