Skip to content

Commit

Permalink
lib/libtest.sh: add -t option to pipe-pane sub-command to avoid ...
Browse files Browse the repository at this point in the history
to avoid get wrong session(pane) log while run in nested tmux

Signed-off-by: Jianhong Yin <[email protected]>
  • Loading branch information
tcler committed Jan 12, 2025
1 parent eb3e560 commit ac0f7e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ run() {
local _nohup= _nohuplogf=
local _user= _SUDO=
local _default_nohuplogf=
local _tmuxSession= _tmuxlogf= _tmuxSOpt=
local _tmuxSession= _tmuxlogf= _tmuxSOpt= _ppaneOpt=
local _xrcrange= _chkrc=no
local _logf=

Expand Down Expand Up @@ -183,9 +183,11 @@ run() {
_tmuxSession=${_tmuxSession:-kissrun-$$-${USER}-s$((_TMUX_SID++))}
_tmuxSOpt="-s $_tmuxSession"
_tmuxlogf=${_logf:-${_logpath:-/tmp}/run-tmux-${_tmuxSession}.log}
_ppaneOpt="-t ${_tmuxSession//[:.]/_}:0.0"
if [[ "$_tmuxSession" = - ]]; then
_tmuxSOpt=
_tmuxlogf=/dev/null
_ppaneOpt=
fi
}

Expand All @@ -200,7 +202,7 @@ run() {
if [[ "$_debug" = yes ]]; then
_cmdlx="$_cmdl"
if [[ "${_runtype}" = tmux ]]; then
_cmdlx="tmux new $_tmuxSOpt -d \"$_cmdl\" \\; pipe-pane \"exec cat >$_tmuxlogf\""
_cmdlx="tmux new $_tmuxSOpt -d \"$_cmdl\" \\; pipe-pane $_ppaneOpt \"exec cat >$_tmuxlogf\""
elif [[ "$_nohup" = yes ]]; then
_cmdlx="nohup $_cmdl &>${_nohuplogf} &"
fi
Expand All @@ -219,7 +221,7 @@ run() {
;;
eval) $_SUDO eval "$_cmdl"; _rc=$?;;
bash) $_SUDO bash -c "$_cmdl"; _rc=$?;;
tmux) $_SUDO tmux new $_tmuxSOpt -d "$_cmdl" \; pipe-pane "exec cat >$_tmuxlogf"; _rc=$?;;
tmux) $_SUDO tmux new $_tmuxSOpt -d "$_cmdl" \; pipe-pane $_ppaneOpt "exec cat >$_tmuxlogf"; _rc=$?;;
esac

_RC=$_rc
Expand Down

0 comments on commit ac0f7e7

Please sign in to comment.