diff options
-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 |