aboutsummaryrefslogtreecommitdiff
path: root/xtopen
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-09 20:21:23 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-09 20:21:23 +0200
commit284b2b9f33bc3c8faf03fa77828495655e1054f4 (patch)
treec9ae19c3ae71bbce788c4b5c72e9d8000cc95d54 /xtopen
parente482cc410962335a5bac7b3524f2a3fda8a3cac6 (diff)
downloadxutil-284b2b9f33bc3c8faf03fa77828495655e1054f4.tar.gz
xtopen: Add -K flag (keep window on error)
Diffstat (limited to 'xtopen')
-rwxr-xr-xxtopen17
1 files changed, 14 insertions, 3 deletions
diff --git a/xtopen b/xtopen
index af284e4..540f4bd 100755
--- a/xtopen
+++ b/xtopen
@@ -14,14 +14,25 @@ abbr() {
if [ $# -eq 0 ]; then
xmessage -buttons sorry:0 -default sorry -nearmouse \
- error: missing argument
+ "usage: $0 [-K] cmd ..."
exit 1
fi
+flagK=
+case "$1" in
+-K) flagK=-K
+ shift ;;
+-*) xmessage -buttons sorry:0 -default sorry -nearmouse \
+ error: "unknown flag $1"
+ exit 1 ;;
+esac
+
if ! which "$1" 2>/dev/null; then
xmessage -default okay -nearmouse \
- error: program "$1" not found
+ error: "program $1 not found"
exit 1
fi
-exec xterm -title "$* (`abbr "$PWD"`)" -e "$@"
+[ -z "$flagK" ] &&
+exec xterm -title "$* (`abbr "$PWD"`)" -e "$@" ||
+exec xterm -title "$* (`abbr "$PWD"`)" -e with-shell-on-error "$@"