From 284b2b9f33bc3c8faf03fa77828495655e1054f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 9 Jun 2021 20:21:23 +0200 Subject: xtopen: Add -K flag (keep window on error) --- xtopen | 17 ++++++++++++++--- 1 file 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 "$@" -- cgit v1.2.3