aboutsummaryrefslogtreecommitdiff
path: root/xtopen
diff options
context:
space:
mode:
Diffstat (limited to 'xtopen')
-rwxr-xr-xxtopen30
1 files changed, 18 insertions, 12 deletions
diff --git a/xtopen b/xtopen
index 540f4bd..83bca60 100755
--- a/xtopen
+++ b/xtopen
@@ -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