improved arg parsing

This commit is contained in:
Daniel Langbein 2022-02-20 15:38:05 +01:00
parent 8acf217365
commit eea22e84c8
3 changed files with 31 additions and 11 deletions

View File

@ -1,9 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build-all tmp" type="ShConfigurationType">
<configuration default="false" name="build-all" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/build-pkg/build-all" />
<option name="SCRIPT_OPTIONS" value="pkglist.tmp" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/build-pkg" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />

View File

@ -69,20 +69,40 @@ function space_separated_to_array() {
readarray -d " " -t ptr2 < <(printf '%s' "$ptr")
}
function main() {
# parse arguments
{
if [ $# -lt 1 ]; then
echo "Usage: ${0} <PKGLIST-FILE> [<makepkgArguments>]
function usage() {
echo "Usage:
${0} <PKGLIST-FILE> [-- <makepkgArguments>]
${0} -- <makepkgArguments>
With PKGLIST-FILE a file containing zero or more package names in each line, separated by space.
All packages in a line will be built sequentially and are then synced to the remote repository
before continuing with the next line.";
exit 1;
}
function main() {
# parse arguments
{
if [ "${1}" == '-h' ] || [ "${1}" == '--help' ] ; then
usage
fi
PKGLIST="${1}"
if [ "${1}" == '--' ]; then
shift; # remove first arg
else
# If $1 not set or null, use 'pkglist.tmp'.
PKGLIST="${1:-pkglist.tmp}"
if [ $# -gt 1 ]; then
if [ "${2}" == '--' ]; then
shift; # remove first arg
shift; # remove second arg
else
usage
fi
fi
fi
MAKEPKG_ARGS=("$@")
}

View File

@ -1,5 +1,5 @@
#!/bin/bash
../git-pull || exit $?
./build-all pkglist.tmp || exit $?
./build-all || exit $?
echo '' > pkglist.tmp