Debian Codegraph @

sensible-terminal

raw symbols SCIP
1 #!/bin/sh
2 # Copyright 2007 Jari Aalto;
3 # Copyright 2019-2022 Bastien Roucariès
4
5 # Prevent recursive loops, where environment variables are set to this script
6 [ -n "$__SENSIBLE_TERMINAL" ] && exit 126
7 __SENSIBLE_TERMINAL="$0"
8 export __SENSIBLE_TERMINAL
9
10 Try()
11 {
12 [ -z "$__sensible_candidate" ] && return
13 eval "$__sensible_candidate \"\$@\""; ret=$?
14 # 127=ENOENT, 126=couldn't exec for another reason
15 [ "$ret" -ne 126 ] && [ "$ret" -ne 127 ] && exit "$ret"
16 unset ret
17 }
18
19 for __sensible_candidate in "$TERMINAL_EMULATOR" "$SENSIBLE_TERMINAL_EMULATOR"; do
20 Try "$@"
21 done
22
23 if [ -n "$XDG_CURRENT_DESKTOP" ]; then
24 __sensible_candidate="sensible-terminal-$(echo "$XDG_CURRENT_DESKTOP" | tr '[:upper:]' '[:lower:]')"
25 command -v "$__sensible_candidate" > /dev/null && Try "$@"
26 fi
27
28 __sensible_candidate=x-terminal-emulator
29 Try "$@"
30
31 command -v gettext > /dev/null || alias gettext='printf %s'
32 # shellcheck disable=SC2016
33 TEXTDOMAIN=sensible-utils gettext 'Couldn'\''t find a terminal emulator!
34 Set the $TERMINAL_EMULATOR environment variable to your desired terminal emulator.
35 ' >&2
36 exit 1