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.
This commit is contained in:
slakmagik 2011-03-28 22:40:58 -04:00 committed by Mathias Gumz
parent 2034e5ef44
commit 0fbb2cb73c

View file

@ -44,17 +44,6 @@
# other ways. # 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 # Functions
display_usage() { display_usage() {
cat << EOF cat << EOF
@ -123,6 +112,39 @@ display_authors() {
EOF 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() { find_it() {
[ -n "$1" ] && hash $1 2> /dev/null && shift && "$@" [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@"
} }
@ -532,6 +554,19 @@ N
done done
rm -f ${MENUFILENAME}.tmp 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) # menu defaults (if translation forget to set one of them)
@ -1278,39 +1313,6 @@ EOF
fi fi
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=$@ BACKUPOPTIONS=$@
# Get options. # Get options.
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do