Compare commits
3 commits
eead7fa295
...
383b243ebd
| Author | SHA1 | Date | |
|---|---|---|---|
| 383b243ebd | |||
| f1573d922d | |||
| d64c54f994 |
1 changed files with 6 additions and 8 deletions
|
|
@ -62,9 +62,11 @@ 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
|
||||||
bash -c '\''
|
exec 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."
|
||||||
|
|
@ -92,18 +94,14 @@ 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}< <(
|
builtin exec {ENV}< <(printf "%s\\n%s" "${_s@A}" "$_s")
|
||||||
printf %s "${_s@A}
|
|
||||||
$_s"
|
|
||||||
)
|
|
||||||
|
|
||||||
export ENV="/dev/fd/$ENV"
|
export ENV="/dev/fd/$ENV"
|
||||||
'\''\'\'''\''\'\''\'\'''\'''\''\'\'''\''
|
'\''\'\'''\''\'\''\'\'''\'''\''\'\'''\''
|
||||||
|
|
||||||
'\''\'\'''\''
|
'\''\'\'''\''
|
||||||
|
|
||||||
printf %s "${_s@A}
|
printf "%s\\n%s" "${_s@A}" "$_s"
|
||||||
$_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
|
||||||
|
|
@ -145,7 +143,7 @@ bashrc_forward () {
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
exec "${SHELL:-${0#-}}" "$@"
|
exec "${SHELL:-${0#-}}" "$@"
|
||||||
else
|
else
|
||||||
>&2 echo "Failed to SSH with .bashrc-forwarding, could not find Bash binary."
|
>&2 echo "Failed to forward .bashrc, 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