From 0fbb2cb73cee7a28c9f9ac2ec52f221cc53febef Mon Sep 17 00:00:00 2001 From: slakmagik Date: Mon, 28 Mar 2011 22:40:58 -0400 Subject: 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. --- util/fluxbox-generate_menu.in | 90 ++++++++++++++++++++++--------------------- 1 file 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 @@ # other ways. -WHOAMI=`whoami` -[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin - -# Check for Imlib2-support -if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then - PNG_ICONS="yes" -else - # better assume to assume "no" - PNG_ICONS="no" -fi - # Functions display_usage() { cat << EOF @@ -123,6 +112,39 @@ display_authors() { EOF } +testoption() { + if [ -z "$3" -o -n "`echo $3|grep '^-'`" ]; then + echo "Error: The option $2 requires an argument." >&2 + exit 1 + fi + case $1 in + ex) # executable + if find_it "$3"; then + : + else + echo "Error: The option $2 needs an executable as argument, and \`$3' is not." >&2 + fi + ;; + di) # directory + if [ -d "$3" ]; then + : + else + echo "Error: The option $2 needs a directory as argument, and \`$3' is not." >&2 + fi + ;; + fl) # file + if [ -r "$3" ]; then + : + else + echo "Error: The option $2 needs a readable file as argument, and \`$3' is not." >&2 + fi + ;; + sk) # skip + : + ;; + esac +} + find_it() { [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@" } @@ -532,6 +554,19 @@ N done rm -f ${MENUFILENAME}.tmp } +# End functions + + +WHOAMI=`whoami` +[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin + +# Check for Imlib2-support +if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then + PNG_ICONS="yes" +else + # better assume to assume "no" + PNG_ICONS="no" +fi # menu defaults (if translation forget to set one of them) @@ -1278,39 +1313,6 @@ EOF fi fi -testoption() { - if [ -z "$3" -o -n "`echo $3|grep '^-'`" ]; then - echo "Error: The option $2 requires an argument." >&2 - exit 1 - fi - case $1 in - ex) # executable - if find_it "$3"; then - : - else - echo "Error: The option $2 needs an executable as argument, and \`$3' is not." >&2 - fi - ;; - di) # directory - if [ -d "$3" ]; then - : - else - echo "Error: The option $2 needs a directory as argument, and \`$3' is not." >&2 - fi - ;; - fl) # file - if [ -r "$3" ]; then - : - else - echo "Error: The option $2 needs a readable file as argument, and \`$3' is not." >&2 - fi - ;; - sk) # skip - : - ;; - esac -} - BACKUPOPTIONS=$@ # Get options. while [ $# -gt 0 ]; do -- cgit v0.11.2