diff --git a/scripts/xdg-terminal.in b/scripts/xdg-terminal.in index 614dacf..fd958be 100644 --- a/scripts/xdg-terminal.in +++ b/scripts/xdg-terminal.in @@ -111,26 +111,43 @@ terminal_generic() { # if $TERM is a known non-command, use hard-coded fallbacks if [ x"$TERM" = x"" ] || [ x"$TERM" = x"linux" ] || [ x"$TERM" = x"vt100" ]; then - TERM=xterm + TERM=urxvt:rxvt:xterm fi - terminal_exec=`which $TERM 2>/dev/null` - - if [ -x "$terminal_exec" ]; then - if [ x"$1" = x"" ]; then - $terminal_exec - else - $terminal_exec -e "$1" + # treat $TERM like $BROWSER to allow a fallback chain + IFS=":" + for terminal in $TERM; do + unset IFS + if [ x"$terminal" != x"" ]; then + terminal_exec=`which $terminal 2>/dev/null` + + if [ -x "$terminal_exec" ]; then + if [ x"$1" = x"" ]; then + $terminal_exec + else + # screen and urxvt won't do their own parsing of quoted arguments + if [ x"$TERM" = x"screen" ]; then + # screen has an incompatible meaning for -e + sh -c "exec $terminal_exec $1" + elif [ x"$TERM" = x"urxvt" ] || [ x"$TERM" = x"rxvt-unicode" ] || [ x"$TERM" = x"rxvt" ]; then + #TODO: Use whatever mechanism dash supports to test for + # rxvt-* to match things like rxvt-unicode-256color + sh -c "exec $terminal_exec -e $1" + else + $terminal_exec -e "$1" + fi + fi + + if [ $? -eq 0 ]; then + exit_success + else + exit_failure_operation_failed + fi + fi fi + done - if [ $? -eq 0 ]; then - exit_success - else - exit_failure_operation_failed - fi - else - exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable" - fi + exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable" } terminal_lxde()