Removed recursive script dependency in filename and moved usage lock to start of usage. Should prevent an infinite loop caused by usage checking.
This commit is contained in:
parent
ee68a72f60
commit
e4f2291427
|
@ -2,6 +2,11 @@
|
|||
# Cuts the name of a single file or list of files out from its path and echoes it.
|
||||
# Otherwise, does nothing.
|
||||
|
||||
lastarg () {
|
||||
for last in "$@" ; do :; done
|
||||
echo "$last"
|
||||
}
|
||||
|
||||
IFS='/'
|
||||
NAME="$(lastarg $0)"
|
||||
USAGE="Usage: $NAME [filenames...]"
|
||||
|
|
|
@ -3,25 +3,25 @@
|
|||
# Requires: <program> <package (Devuan)>
|
||||
# echo coreutils
|
||||
|
||||
NAME="$(filename $0)"
|
||||
IFS='
|
||||
if [ -z $USAGE_LOCK ] ; then
|
||||
export USAGE_LOCK=1
|
||||
NAME="$(filename $0)"
|
||||
IFS='
|
||||
'
|
||||
MESSAGE="$(lastarg $@)"
|
||||
AGAINST="$(nolastarg $@)"
|
||||
IFS=' '
|
||||
MESSAGE="$(lastarg $@)"
|
||||
AGAINST="$(nolastarg $@)"
|
||||
IFS=' '
|
||||
|
||||
if ( [ "$1" = "-h" ] || [ "$1" = "--help" ] ) && [ "$2" = "" ] ; then
|
||||
echo "Usage: $NAME [args to check] <usage string> "
|
||||
else
|
||||
CHECK='-h
|
||||
if ( [ "$1" = "-h" ] || [ "$1" = "--help" ] ) && [ "$2" = "" ] ; then
|
||||
echo "Usage: $NAME [args to check] <usage string> "
|
||||
else
|
||||
CHECK='-h
|
||||
--help'
|
||||
if [ "$1" != "" ] ; then
|
||||
if [ -z $USAGE_LOCK ] ; then
|
||||
export USAGE_LOCK=1
|
||||
echo $CHECK | linefirstargdo firstargnthargdo $(( 4 + $# )) firstnthpipedo $(( $# - 1 )) "$AGAINST" invertstatus linematchfirstargdo echo "$MESSAGE"
|
||||
CODE="$?"
|
||||
unset USAGE_LOCK
|
||||
exit $CODE
|
||||
if [ "$1" != "" ] ; then
|
||||
echo $CHECK | linefirstargdo firstargnthargdo $(( 4 + $# )) firstnthpipedo $(( $# - 1 )) "$AGAINST" invertstatus linematchfirstargdo echo "$MESSAGE"
|
||||
CODE="$?"
|
||||
unset USAGE_LOCK
|
||||
exit $CODE
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue