Compare commits
No commits in common. "383b243ebdff98b4ccef3947e771b2fee2b00466" and "eead7fa295f7f609f7ad81df6a2e058c39902cab" have entirely different histories.
383b243ebd
...
eead7fa295
1 changed files with 8 additions and 6 deletions
|
|
@ -62,11 +62,9 @@ bashrc_forward () {
|
||||||
printf %s '
|
printf %s '
|
||||||
#-# If bashrc was forwarded using environment variable, unset it, since we do not need it anymore and to keep the env clean. Relaying will set it anyways to something fresh.
|
#-# If bashrc was forwarded using environment variable, unset it, since we do not need it anymore and to keep the env clean. Relaying will set it anyways to something fresh.
|
||||||
unset FORWARDED_BASHRC
|
unset FORWARDED_BASHRC
|
||||||
#-# Set default IFS, since our staging command line may not contain double quotes since they behave weirdly in powershell.
|
|
||||||
IFS=$(printf '\'' \t\n.'\''); IFS=${IFS%.}
|
|
||||||
_argv_wrap () {
|
_argv_wrap () {
|
||||||
if >/dev/null 2>&1 command -v bash; then
|
if >/dev/null 2>&1 command -v bash; then
|
||||||
exec bash -c '\''
|
bash -c '\''
|
||||||
#-# Newest Bash feature used here is parameter transformation (`${_s@A}`), introduced in Bash 4.4
|
#-# Newest Bash feature used here is parameter transformation (`${_s@A}`), introduced in Bash 4.4
|
||||||
if ! ((BASH_VERSINFO[0]>4||(BASH_VERSINFO[0]==4&&BASH_VERSINFO[1]>=4))) 2>/dev/null; then
|
if ! ((BASH_VERSINFO[0]>4||(BASH_VERSINFO[0]==4&&BASH_VERSINFO[1]>=4))) 2>/dev/null; then
|
||||||
>&2 echo "Failed to SSH with .bashrc-forwarding, the Bash version is too old."
|
>&2 echo "Failed to SSH with .bashrc-forwarding, the Bash version is too old."
|
||||||
|
|
@ -94,14 +92,18 @@ bashrc_forward () {
|
||||||
[[ "${ENV##*/}" =~ ^[0-9]+$ ]] && builtin eval "builtin exec ${ENV##*/}<&-"
|
[[ "${ENV##*/}" =~ ^[0-9]+$ ]] && builtin eval "builtin exec ${ENV##*/}<&-"
|
||||||
|
|
||||||
#-# Constructs new ENV after every command, thanks to the quine
|
#-# Constructs new ENV after every command, thanks to the quine
|
||||||
builtin exec {ENV}< <(printf "%s\\n%s" "${_s@A}" "$_s")
|
builtin exec {ENV}< <(
|
||||||
|
printf %s "${_s@A}
|
||||||
|
$_s"
|
||||||
|
)
|
||||||
|
|
||||||
export ENV="/dev/fd/$ENV"
|
export ENV="/dev/fd/$ENV"
|
||||||
'\''\'\'''\''\'\''\'\'''\'''\''\'\'''\''
|
'\''\'\'''\''\'\''\'\'''\'''\''\'\'''\''
|
||||||
|
|
||||||
'\''\'\'''\''
|
'\''\'\'''\''
|
||||||
|
|
||||||
printf "%s\\n%s" "${_s@A}" "$_s"
|
printf %s "${_s@A}
|
||||||
|
$_s"
|
||||||
|
|
||||||
#-# Suppress the warning `bash: POSIXLY_CORRECT: readonly variable` using a one-shot DEBUG trap
|
#-# Suppress the warning `bash: POSIXLY_CORRECT: readonly variable` using a one-shot DEBUG trap
|
||||||
#-# `PS0` and `PROMPT_COMMAND` will not suffice, `PROMPT_COMMAND` runs AFTER the command, therefore
|
#-# `PS0` and `PROMPT_COMMAND` will not suffice, `PROMPT_COMMAND` runs AFTER the command, therefore
|
||||||
|
|
@ -143,7 +145,7 @@ bashrc_forward () {
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
exec "${SHELL:-${0#-}}" "$@"
|
exec "${SHELL:-${0#-}}" "$@"
|
||||||
else
|
else
|
||||||
>&2 echo "Failed to forward .bashrc, could not find Bash binary."
|
>&2 echo "Failed to SSH with .bashrc-forwarding, could not find Bash binary."
|
||||||
>&2 echo "Please install Bash 4.4 or newer on the target system and make it available in the PATH."
|
>&2 echo "Please install Bash 4.4 or newer on the target system and make it available in the PATH."
|
||||||
>&2 echo "Falling back to default shell (warning, possibly not a login shell anymore!): '\''${SHELL:-${0#-}}'\''."
|
>&2 echo "Falling back to default shell (warning, possibly not a login shell anymore!): '\''${SHELL:-${0#-}}'\''."
|
||||||
#-# Using generic `exec` call instead of fancy `exec -l --` because we cannot assume that we are inside Bash.
|
#-# Using generic `exec` call instead of fancy `exec -l --` because we cannot assume that we are inside Bash.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue