sync: add automatic GPG key retrieval
[aurutils.git] / tests / parseopt-consistency
blob986deaa50c1a7359e78f12ac33bb8225dffa397c
1 #!/bin/bash
2 shopt -s extglob
3 shopt -s nullglob
4 export AUR_ASROOT=1
6 parse_loop() {
7 awk '/^while true; do$/,/^done$/ {
8 if ( $0 ~ /^\s*-.*)$/ && $1 != "--)" ) { # match -<something>) except --)
9 gsub(/[ )]/,"") # remove spaces and final parens
10 split($0, patterns,"|") # split on |
11 getline # ask for next line for shift check
12 for (i in patterns) { # print options accordingly
13 if ($2 ~ /^optval/) {
14 print patterns[i] "::"
15 } else if ($1 ~ /^shift/) {
16 print patterns[i] ":"
17 } else {
18 print patterns[i]
25 ret=0
26 have_optdump=(aur-build aur-chroot aur-fetch aur-pkglist aur-repo aur-repo-filter aur-srcver aur-sync aur-vercmp aur-view)
27 for cmd in "${have_optdump[@]}"; do
28 aurcmd=${BASH_SOURCE%/*}/../lib/$cmd
30 diff --color -U0 --label "$aurcmd Options" --label "$aurcmd Loop" \
31 <(bash --pretty-print -O extglob "$aurcmd" | parse_loop | sort) \
32 <(AUR_DEBUG=1 command "$aurcmd" --dump-options 2>/dev/null | sort)
33 ((ret|=$?))
34 done
36 exit $ret