From eead7fa295f7f609f7ad81df6a2e058c39902cab Mon Sep 17 00:00:00 2001 From: cubernetes Date: Wed, 21 Oct 2026 11:06:39 +0200 Subject: [PATCH] When parameters are passed and bash exists, execute them after forwarding, in case user wants to do append sth. like `-ic l` to use the l aliases noninteractively --- bashrc-forward.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bashrc-forward.sh b/bashrc-forward.sh index 54f293c..3d064b6 100644 --- a/bashrc-forward.sh +++ b/bashrc-forward.sh @@ -65,10 +65,8 @@ bashrc_forward () { _argv_wrap () { if >/dev/null 2>&1 command -v bash; then bash -c '\'' - if [ "$#" -gt 0 ]; then - builtin exec -- bash "$@" #-# Newest Bash feature used here is parameter transformation (`${_s@A}`), introduced in Bash 4.4 - elif ! ((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 "Please install Bash 4.4 or newer on the target system and make it available in the PATH." >&2 echo "Falling back to default login shell: '\''\'\'''\''${SHELL:-${0#-}}'\''\'\'''\''." @@ -133,7 +131,7 @@ bashrc_forward () { )" DEBUG '\''\'\'''\'' ) \ - builtin exec -a sh bash -l # TODO: Login shell is only the default with SSH. With docker run, for example, it is not! + builtin exec -a sh bash -l "$@" # TODO: Login shell is only the default with SSH. With docker run, for example, it is not! #-# Note for the exec above: `ENV` is read if and only if bash is invoked as `sh` (or `-sh`), which we enforce using `exec -a sh ...`. #-# Additionally, when invoked just as `sh`, it never reads `~/.bashrc` (or `/etc/bash.bashrc`), because of the implicit posix mode. #-# When invoked as a login shell however (either by having a leading dash in `argv[0]` or with `--login/-l`),