aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorslakmagik <slakmagik@gmail.com>2011-03-29 02:40:58 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2011-03-29 06:44:51 (GMT)
commit0fbb2cb73cee7a28c9f9ac2ec52f221cc53febef (patch)
treee3cd8fc036fdcc343b43cde8f3bbb5a102df9ee7 /util
parent2034e5ef44fc7b1bf9c3443c4e7ee999a164e0b0 (diff)
downloadfluxbox-0fbb2cb73cee7a28c9f9ac2ec52f221cc53febef.zip
fluxbox-0fbb2cb73cee7a28c9f9ac2ec52f221cc53febef.tar.bz2
separate functions and main code
Transpose one function from main to the rest of the functions and one block from the top of the script to the top of main. Add an 'End functions' comment.
Diffstat (limited to 'util')
-rwxr-xr-xutil/fluxbox-generate_menu.in90
1 files changed, 46 insertions, 44 deletions
diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in
index 7f62feb..6e5b7a8 100755
--- a/util/fluxbox-generate_menu.in
+++ b/util/fluxbox-generate_menu.in
@@ -44,17 +44,6 @@
44# other ways. 44# other ways.
45 45
46 46
47WHOAMI=`whoami`
48[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
49
50# Check for Imlib2-support
51if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then
52 PNG_ICONS="yes"
53else
54 # better assume to assume "no"
55 PNG_ICONS="no"
56fi
57
58# Functions 47# Functions
59display_usage() { 48display_usage() {
60 cat << EOF 49 cat << EOF
@@ -123,6 +112,39 @@ display_authors() {
123EOF 112EOF
124} 113}
125 114
115testoption() {
116 if [ -z "$3" -o -n "`echo $3|grep '^-'`" ]; then
117 echo "Error: The option $2 requires an argument." >&2
118 exit 1
119 fi
120 case $1 in
121 ex) # executable
122 if find_it "$3"; then
123 :
124 else
125 echo "Error: The option $2 needs an executable as argument, and \`$3' is not." >&2
126 fi
127 ;;
128 di) # directory
129 if [ -d "$3" ]; then
130 :
131 else
132 echo "Error: The option $2 needs a directory as argument, and \`$3' is not." >&2
133 fi
134 ;;
135 fl) # file
136 if [ -r "$3" ]; then
137 :
138 else
139 echo "Error: The option $2 needs a readable file as argument, and \`$3' is not." >&2
140 fi
141 ;;
142 sk) # skip
143 :
144 ;;
145 esac
146}
147
126find_it() { 148find_it() {
127 [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@" 149 [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@"
128} 150}
@@ -532,6 +554,19 @@ N
532done 554done
533rm -f ${MENUFILENAME}.tmp 555rm -f ${MENUFILENAME}.tmp
534} 556}
557# End functions
558
559
560WHOAMI=`whoami`
561[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
562
563# Check for Imlib2-support
564if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then
565 PNG_ICONS="yes"
566else
567 # better assume to assume "no"
568 PNG_ICONS="no"
569fi
535 570
536# menu defaults (if translation forget to set one of them) 571# menu defaults (if translation forget to set one of them)
537 572
@@ -1278,39 +1313,6 @@ EOF
1278 fi 1313 fi
1279fi 1314fi
1280 1315
1281testoption() {
1282 if [ -z "$3" -o -n "`echo $3|grep '^-'`" ]; then
1283 echo "Error: The option $2 requires an argument." >&2
1284 exit 1
1285 fi
1286 case $1 in
1287 ex) # executable
1288 if find_it "$3"; then
1289 :
1290 else
1291 echo "Error: The option $2 needs an executable as argument, and \`$3' is not." >&2
1292 fi
1293 ;;
1294 di) # directory
1295 if [ -d "$3" ]; then
1296 :
1297 else
1298 echo "Error: The option $2 needs a directory as argument, and \`$3' is not." >&2
1299 fi
1300 ;;
1301 fl) # file
1302 if [ -r "$3" ]; then
1303 :
1304 else
1305 echo "Error: The option $2 needs a readable file as argument, and \`$3' is not." >&2
1306 fi
1307 ;;
1308 sk) # skip
1309 :
1310 ;;
1311 esac
1312}
1313
1314BACKUPOPTIONS=$@ 1316BACKUPOPTIONS=$@
1315# Get options. 1317# Get options.
1316while [ $# -gt 0 ]; do 1318while [ $# -gt 0 ]; do