1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
From 18f6deb82dfe567a414d9747566d8960b42e4cd6 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Sat, 19 Dec 2009 15:08:33 +0200
Subject: [PATCH] xtitle.sh: Add Help(). Write to stdout, not stderr. Simplyfy options.
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
xtitle.sh | 47 +++++++++++++++++++++--------------------------
1 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/xtitle.sh b/xtitle.sh
index b83e1b2..e0dd82f 100755
--- a/xtitle.sh
+++ b/xtitle.sh
@@ -33,23 +33,35 @@ PATH=/bin:/usr/bin; export PATH
version=1.0.1 # 2009-12-10: add copyright/GPL notice for debian pkg
version=1.0.2 # 2009-12-18: add -V option, long options
+Help ()
+{
+ echo "\
+usage: $0 [ -tiq ] string ... | -V
+ -t, --title set window title
+ -i, --icon set icon name
+ -q, --quiet quiet mode, don't report settings
+ -V, --version only output program version
+Without -t or -i options, both the window title and icon name are set.
+Version $version"
+
+ exit 0
+}
+
dflttarg=ti
-target=; bad=
+target=
while :
do
case $# in
0) break;;
*) case "$1" in
- -[tiqV]*) target="${target}$1";;
- --title) target="${target}-t";;
- --icon) target="${target}-i";;
- --quiet) target="${target}-q";;
- --version) target="${target}-V";;
-
+ -h|--help) Help ;;
+ -i|--icon) target="${target}-i";;
+ -q|--quiet) target="${target}-q";;
+ -t|--title) target="${target}-t";;
+ -V|--version) echo $version ; exit 0 ;;
+ -*) echo "$0: unknown option ($1)" 1>&2 ;;
--) shift; break;;
- -h|--help) bad=t; break;;
- -*) bad=t; echo "$0: unknown option ($1)" 1>&2;;
*) break;;
esac
shift;;
@@ -57,23 +69,6 @@ do
done
case "$target" in
-*V*) echo "$version"; exit 0;;
-esac
-
-case "$#,$bad" in
-0,*|*,?*) cat << EOF 1>&2
-usage: $0 [ -tiq ] string ... | -V
- -t, --title set window title
- -i, --icon set icon name
- -q, --quiet quiet mode, don't report settings
- -V, --version only output program version
-Without -t or -i options, both the window title and icon name are set.
-Version $version
-EOF
- exit 1;;
-esac
-
-case "$target" in
''|-q) target="$target$dflttarg";;
esac
--
1.6.5
|