Package: xtitle / 1.0.2-6

40-help.patch Patch series | download
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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.
 Replace -q with --verbose option

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 xtitle.sh |   63 +++++++++++++++++++++++++++++---------------------------------
 1 file changed, 30 insertions(+), 33 deletions(-)

--- a/xtitle.sh
+++ b/xtitle.sh
@@ -33,59 +33,56 @@
 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
 
-dflttarg=ti
-target=; bad=
+Help ()
+{
+    echo "\
+usage: $0 [ -itvV ] string ...
+	-i, --icon	set icon name
+	-t, --title	set window title
+	-v, --verbose	display informational messages
+	-V, --version	only output program version
+Without -i or -t options, both the window title and icon name are set.
+Version $version"
+
+    exit 0
+}
+
+default="-t-i"  # flags
+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";;
-
-		--)		shift; break;;
-		-h|--help)	bad=t; break;;
-		-*)		bad=t; echo "$0: unknown option ($1)" 1>&2;;
-		*)		break;;
+		-h|--help)      Help ;;
+		-i|--icon)	target="${target}-i" ;;
+		-t|--title)	target="${target}-t" ;;
+		-v|--verbose)	target="${target}-v" ;;
+		-V|--version)	echo $version ; exit 0 ;;
+		-*)		echo "$0: unknown option ($1)" >&2 ;;
+		--)		shift; break ;;
+		*)		break ;;
 		esac
 		shift;;
 	esac
 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
+[ ! "$arget" ] && target=$default
 
 case "$target" in
-''|-q)	target="$target$dflttarg";;
+*i*|*t*) something="something" ;;
 esac
 
 case "$target" in
 *t*)	case "$target" in
-	*q*)	echo "]2;$*" | tr -d '\012';;
-	*)	echo "]2;$*title = $*";;
+	*-v*)	echo "]2;$*title = $*";;
+	*)	echo "]2;$*" | tr -d '\012';;
 	esac;;
 esac
 case "$target" in
 *i*)	case "$target" in
-	*q*)	echo "]1;$*" | tr -d '\012';;
-	*)	echo "]1;$*icon  = $*";;
+	*-v*)	echo "]1;$*icon  = $*";;
+	*)	echo "]1;$*" | tr -d '\012';;
 	esac;;
 esac