diff options
author | Stefan Kreutz <mail@skreutz.com> | 2022-05-18 22:18:05 +0200 |
---|---|---|
committer | Stefan Kreutz <mail@skreutz.com> | 2022-05-18 22:18:05 +0200 |
commit | f02ee43b9e2d9fcc5c02eb82082b0ee49f915512 (patch) | |
tree | 910f6951a696795556a6b16a0a029e9a66494339 | |
parent | e4537936f674d71afe96ee2f8a86dad6c3294409 (diff) | |
download | ssh-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-x | ssh-tmux.sh | 2 |
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" |