Merge branch 'ksi-ssh' of https://github.com/page-down/kitty
This commit is contained in:
commit
17c994db57
@ -114,9 +114,9 @@ the TTY, any other requests are responded to by errors.
|
|||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
When connecting to BSD servers, it is possible the bootstrap script will
|
When connecting to BSD servers, it is possible the bootstrap script will
|
||||||
fail or run slowly, because they are crippled in various ways. Your best bet
|
fail or run slowly, because the default shells are crippled in various ways.
|
||||||
is to install python on the server, make sure the login shell is something
|
Your best bet is to install python on the server, make sure the login shell
|
||||||
POSIX sh compliant, not csh, and use :code:`python` as the :opt:`interpreter
|
is something POSIX sh compliant, and use :code:`python` as the :opt:`interpreter
|
||||||
<kitten-ssh.interpreter>` in :file:`ssh.conf`.
|
<kitten-ssh.interpreter>` in :file:`ssh.conf`.
|
||||||
|
|
||||||
.. include:: /generated/conf-kitten-ssh.rst
|
.. include:: /generated/conf-kitten-ssh.rst
|
||||||
|
|||||||
@ -407,10 +407,11 @@ def wrap_bootstrap_script(sh_script: str, interpreter: str) -> List[str]:
|
|||||||
unwrap_script = '''"import base64, sys; eval(compile(base64.standard_b64decode(sys.argv[-1]), 'bootstrap.py', 'exec'))"'''
|
unwrap_script = '''"import base64, sys; eval(compile(base64.standard_b64decode(sys.argv[-1]), 'bootstrap.py', 'exec'))"'''
|
||||||
else:
|
else:
|
||||||
# We cant rely on base64 being available on the remote system, so instead
|
# We cant rely on base64 being available on the remote system, so instead
|
||||||
# we quote the bootstrap script by replacing ' and \ with \v and \f and
|
# we quote the bootstrap script by replacing ' and \ with \v and \f
|
||||||
# surrounding with '
|
# also replacing \n and ! with \r and \b for tcsh
|
||||||
es = "'" + sh_script.replace("'", '\v').replace('\\', '\f') + "'"
|
# finally surrounding with '
|
||||||
unwrap_script = r"""'eval "$(echo "$0" | tr \\\v\\\f \\\047\\\134)"' """
|
es = "'" + sh_script.replace("'", '\v').replace('\\', '\f').replace('\n', '\r').replace('!', '\b') + "'"
|
||||||
|
unwrap_script = r"""'eval "$(echo "$0" | tr \\\v\\\f\\\r\\\b \\\047\\\134\\\n\\\041)"' """
|
||||||
return [interpreter, '-c', unwrap_script, es]
|
return [interpreter, '-c', unwrap_script, es]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -412,6 +412,36 @@ exec_with_shell_integration() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
execute_sh_with_posix_env() {
|
||||||
|
if [ "$login_shell" != "/bin/sh" ]; then return 1; fi
|
||||||
|
if command "$login_shell" -l -c ":" > /dev/null 2> /dev/null; then return 1; fi
|
||||||
|
if [ -z "$shell_integration_dir" ]; then
|
||||||
|
if [ -n "$KITTY_SSH_KITTEN_DATA_DIR" ]; then
|
||||||
|
shell_integration_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR/shell-integration"
|
||||||
|
else
|
||||||
|
die "The data directory is not defined, ssh kitten cannot function."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sh_dir="$shell_integration_dir/sh"
|
||||||
|
if [ ! -d "$sh_dir" ]; then mkdir -p "$sh_dir" || die "Creating data directory failed"; fi
|
||||||
|
# Source /etc/profile, ~/.profile, and then check and source ENV
|
||||||
|
echo '
|
||||||
|
if [ -n "$KITTY_SH_INJECT" ]; then
|
||||||
|
unset ENV; unset KITTY_SH_INJECT
|
||||||
|
_ksi_safe_source() { if [ -f "$1" -a -r "$1" ]; then . "$1"; return 0; fi; return 1; }
|
||||||
|
if [ -n "$KITTY_SH_POSIX_ENV" ]; then export ENV="$KITTY_SH_POSIX_ENV"; fi
|
||||||
|
unset KITTY_SH_POSIX_ENV
|
||||||
|
_ksi_safe_source "/etc/profile"; _ksi_safe_source "${HOME-}/.profile"
|
||||||
|
if [ -n "$ENV" ]; then _ksi_safe_source "$ENV"; fi
|
||||||
|
fi' > "$sh_dir/login_shell_env.sh"
|
||||||
|
export KITTY_SH_INJECT=1
|
||||||
|
if [ -n "$ENV" ]; then
|
||||||
|
export KITTY_SH_POSIX_ENV="$ENV"
|
||||||
|
fi
|
||||||
|
export ENV="$sh_dir/login_shell_env.sh"
|
||||||
|
exec "$login_shell"
|
||||||
|
}
|
||||||
|
|
||||||
# Used in the tests
|
# Used in the tests
|
||||||
TEST_SCRIPT
|
TEST_SCRIPT
|
||||||
|
|
||||||
@ -422,10 +452,14 @@ case "$KITTY_SHELL_INTEGRATION" in
|
|||||||
;;
|
;;
|
||||||
(*)
|
(*)
|
||||||
# not blank
|
# not blank
|
||||||
q=$(printf "%s" "$KITTY_SHELL_INTEGRATION" | command grep '\bno-rc\b')
|
if [ -n "$shell_integration_dir" ]; then
|
||||||
if [ -z "$q" ]; then
|
q=$(printf "%s" "$KITTY_SHELL_INTEGRATION" | command grep '\bno-rc\b')
|
||||||
exec_with_shell_integration
|
if [ -z "$q" ]; then
|
||||||
# exec failed, unset
|
exec_with_shell_integration
|
||||||
|
# exec failed, unset
|
||||||
|
unset KITTY_SHELL_INTEGRATION
|
||||||
|
fi
|
||||||
|
else
|
||||||
unset KITTY_SHELL_INTEGRATION
|
unset KITTY_SHELL_INTEGRATION
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -437,4 +471,5 @@ esac
|
|||||||
[ "$(exec -a echo echo OK 2> /dev/null)" = "OK" ] && exec -a "-$shell_name" $login_shell
|
[ "$(exec -a echo echo OK 2> /dev/null)" = "OK" ] && exec -a "-$shell_name" $login_shell
|
||||||
execute_with_python
|
execute_with_python
|
||||||
execute_with_perl
|
execute_with_perl
|
||||||
|
execute_sh_with_posix_env
|
||||||
exec $login_shell "-l"
|
exec $login_shell "-l"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user