diff options
author | slakmagik <slakmagik@gmail.com> | 2011-03-29 02:40:58 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2011-03-29 06:44:51 (GMT) |
commit | 0fbb2cb73cee7a28c9f9ac2ec52f221cc53febef (patch) | |
tree | e3cd8fc036fdcc343b43cde8f3bbb5a102df9ee7 /util | |
parent | 2034e5ef44fc7b1bf9c3443c4e7ee999a164e0b0 (diff) | |
download | fluxbox-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-x | util/fluxbox-generate_menu.in | 90 |
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 | ||
47 | WHOAMI=`whoami` | ||
48 | [ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin | ||
49 | |||
50 | # Check for Imlib2-support | ||
51 | if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then | ||
52 | PNG_ICONS="yes" | ||
53 | else | ||
54 | # better assume to assume "no" | ||
55 | PNG_ICONS="no" | ||
56 | fi | ||
57 | |||
58 | # Functions | 47 | # Functions |
59 | display_usage() { | 48 | display_usage() { |
60 | cat << EOF | 49 | cat << EOF |
@@ -123,6 +112,39 @@ display_authors() { | |||
123 | EOF | 112 | EOF |
124 | } | 113 | } |
125 | 114 | ||
115 | testoption() { | ||
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 | |||
126 | find_it() { | 148 | find_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 | |||
532 | done | 554 | done |
533 | rm -f ${MENUFILENAME}.tmp | 555 | rm -f ${MENUFILENAME}.tmp |
534 | } | 556 | } |
557 | # End functions | ||
558 | |||
559 | |||
560 | WHOAMI=`whoami` | ||
561 | [ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin | ||
562 | |||
563 | # Check for Imlib2-support | ||
564 | if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then | ||
565 | PNG_ICONS="yes" | ||
566 | else | ||
567 | # better assume to assume "no" | ||
568 | PNG_ICONS="no" | ||
569 | fi | ||
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 |
1279 | fi | 1314 | fi |
1280 | 1315 | ||
1281 | testoption() { | ||
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 | |||
1314 | BACKUPOPTIONS=$@ | 1316 | BACKUPOPTIONS=$@ |
1315 | # Get options. | 1317 | # Get options. |
1316 | while [ $# -gt 0 ]; do | 1318 | while [ $# -gt 0 ]; do |