summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kreutz <mail@skreutz.com>2022-05-18 22:18:05 +0200
committerStefan Kreutz <mail@skreutz.com>2022-05-18 22:18:05 +0200
commitf02ee43b9e2d9fcc5c02eb82082b0ee49f915512 (patch)
tree910f6951a696795556a6b16a0a029e9a66494339
parente4537936f674d71afe96ee2f8a86dad6c3294409 (diff)
downloadssh-tmux-f02ee43b9e2d9fcc5c02eb82082b0ee49f915512.tar
Replace trap with sub-shell
The trap may be overwritten by the user's command. The sub-shell is safe.
-rwxr-xr-xssh-tmux.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/ssh-tmux.sh b/ssh-tmux.sh
index a7a7bac..2568e24 100755
--- a/ssh-tmux.sh
+++ b/ssh-tmux.sh
@@ -43,6 +43,6 @@ if [ $# -eq 0 ]; then
err_exit "missing command argument"
fi
-cmd="\"\$SHELL\" -ilc 'trap '\''ret=\$? ; [ \$ret -eq 0 ] || print -u2 -- \"[exited with status \$ret]\" ; exec \"\$SHELL\"'\'' EXIT INT ; $*'"
+cmd="\"\$SHELL\" -ilc '( $* ) || print -u2 -- \"[exited with status \$?]\" ; exec \"\$SHELL\"'"
exec ssh -t "$host" -- tmux new-session ${detach:+-d} ${session:+-s \"$session\"} ${window:+-n \"$window\"} "$cmd"
Generated by cgit. See skreutz.com for my tech blog and contact information.