From f02ee43b9e2d9fcc5c02eb82082b0ee49f915512 Mon Sep 17 00:00:00 2001 From: Stefan Kreutz Date: Wed, 18 May 2022 22:18:05 +0200 Subject: Replace trap with sub-shell The trap may be overwritten by the user's command. The sub-shell is safe. --- ssh-tmux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- cgit v1.2.3