Make: Fix src/scripts/tarball argument parsing
The test for -x uses non-portable operator ==. Screwed up in commit63c6dd6
. Fix by using getopts instead. Missing mandatory arguments aren't diagnosed. Screwed up in initial commit1991652
, v4.3.0. Fix by checking shift's return status. The error message for missing argument of -C neglects to print $0 and uses echo in a non-portable way. Also screwed up in commit1991652
. Fix the obvious way. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
8e8bed5865
commit
b0bea7418a
1 changed files with 20 additions and 10 deletions
|
@ -1,20 +1,30 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
if [ $# = 0 ]; then
|
usage()
|
||||||
|
{
|
||||||
echo "Usage: $0 [-x TWEAK-SCRIPT ] NAME VERSION (FILE | -C DIR)..."
|
echo "Usage: $0 [-x TWEAK-SCRIPT ] NAME VERSION (FILE | -C DIR)..."
|
||||||
exit 1
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
script=:
|
script=:
|
||||||
if [ "$1" == -x ]
|
while getopts x: opt
|
||||||
then
|
do
|
||||||
script=$2
|
case $opt in
|
||||||
shift; shift
|
x)
|
||||||
fi
|
script="$OPTARG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage; exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
name="$1"
|
name="$1"
|
||||||
version="$2"
|
version="$2"
|
||||||
shift; shift
|
if shift 2
|
||||||
|
then :
|
||||||
|
else usage; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
nv=$name-$version
|
nv=$name-$version
|
||||||
mkdir $nv
|
mkdir $nv
|
||||||
|
@ -27,7 +37,7 @@ until [ $# = 0 ]; do
|
||||||
if [ "$1" = -C ]; then
|
if [ "$1" = -C ]; then
|
||||||
dir="$2"
|
dir="$2"
|
||||||
if shift 2; then continue; fi
|
if shift 2; then continue; fi
|
||||||
echo "-C requires an argument" >&2
|
echo "$0: -C requires an argument" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p `dirname "$nv/$1"`
|
mkdir -p `dirname "$nv/$1"`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue