diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-18 21:04:36 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-18 21:04:36 +0200 |
commit | 1a5ad4a82ca79ca693ee5fbed3478ab20fbedadf (patch) | |
tree | 2ef979e45919712c0087bcaa72c4547b042956d7 | |
parent | 7dbdef86487cbfcc23df0113da1c40ca834480ac (diff) | |
download | xutil-1a5ad4a82ca79ca693ee5fbed3478ab20fbedadf.tar.gz |
xtopen: Add -k option (keep open)
-rwxr-xr-x | xtopen | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -14,18 +14,22 @@ abbr() { if [ $# -eq 0 ]; then xmessage -buttons sorry:0 -default sorry -nearmouse \ - "usage: $0 [-K] cmd ..." + "usage: $0 [-k] [-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 +k= +K= +while getopts kK o; do + case $o in + K) K=1 ;; + k) k=1 ;; + ?) xmessage -buttons sorry:0 -default sorry -nearmouse \ + error: "unknown flag $1" + exit 1 ;; + esac +done +shift $((OPTIND-1)) if ! which "$1" 2>/dev/null; then xmessage -default okay -nearmouse \ @@ -33,6 +37,8 @@ if ! which "$1" 2>/dev/null; then exit 1 fi -[ -z "$flagK" ] && -exec xterm -title "$* (`abbr "$PWD"`)" -e "$@" || -exec xterm -title "$* (`abbr "$PWD"`)" -e with-shell-on-error "$@" +case "$k,$K" in +1,*) exec xterm -title "$* (`abbr "$PWD"`)" -e with-shell "$@" ;; +*,1) exec xterm -title "$* (`abbr "$PWD"`)" -e with-shell-on-error "$@" ;; +*,*) exec xterm -title "$* (`abbr "$PWD"`)" -e "$@" ;; +esac |