Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/nit-picker
diff options
context:
space:
mode:
Diffstat (limited to 'bin/nit-picker')
-rwxr-xr-xbin/nit-picker63
1 files changed, 41 insertions, 22 deletions
diff --git a/bin/nit-picker b/bin/nit-picker
index bf3bd13..d313586 100755
--- a/bin/nit-picker
+++ b/bin/nit-picker
@@ -17,35 +17,54 @@
# - check for differences of dependencies between mysql and packages
# - check for installability of packages
-if [ $# -ge 1 ] && [ "x$1" = 'x-n' ]; then
- >&2 echo 'not joining irc'
- irc=false
- repair_dependencies=false
- shift
-elif [ $# -ge 1 ] && [ "x$1" = 'x-r' ]; then
- >&2 echo 'repair all wrong dependencies (remove superfluid, add missing)'
- irc=false
- repair_dependencies=true
+# shellcheck disable=SC2016
+print_usage() {
+ >&2 echo 'usage: nit-picker [-n|-r] [$single_test]'
+ >&2 echo ' -n: Do not join irc.'
+ >&2 echo ' -r: Remove superfluid dependencies in the database.'
+ >&2 echo ' To avoid catastrophic breakage, this option requires'
+ >&2 echo ' $single_test being set.'
+ >&2 echo ' $single_test: Only execute the given test.'
+}
+
+irc=true
+repair_dependencies=false
+
+while [ $# -ge 1 ]; do
+ case "$1" in
+ '-n')
+ >&2 echo 'not joining irc'
+ irc=false
+ ;;
+ '-r')
+ >&2 echo 'repair all wrong dependencies (remove superfluid, add missing)'
+ repair_dependencies=true
+ ;;
+ '-*')
+ >&2 printf 'unknown option "%s"\n' "$1"
+ print_usage
+ exit 1
+ ;;
+ '*')
+ break
+ ;;
+ esac
shift
-else
- irc=true
- repair_dependencies=false
- # shellcheck disable=SC2016
- if [ $# -ne 0 ]; then
- >&2 echo 'usage: nit-picker [-n|-r] [$single_test]'
- >&2 echo ' -n: do not join irc'
- >&2 echo ' -r: remove superfluid dependencies in the database'
- >&2 echo ' $single_test: only execute the given test'
- exit 1
- fi
-fi
+done
-if [ $# -eq 0 ] && ! ${repair_dependencies}; then
+if [ $# -eq 0 ]; then
single_run=false
else
single_run=true
fi
+if ${repair_dependencies} \
+&& ! ${single_run}; then
+ >&2 echo 'Option "-r" needs a test.'
+ print_usage
+ exit 1
+fi
+
clean_up() {
rm -rf --one-file-system "${tmp_dir}"
}