File: check_options

package info (click to toggle)
wget2 1.99.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,468 kB
  • sloc: ansic: 88,607; sh: 10,241; makefile: 501; xml: 182; sed: 16
file content (34 lines) | stat: -rwxr-xr-x 664 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

shopt -s extglob # enable pattern matching for 'case'

DOCFILE=docs/wget2.md
if [ -n "$1" ]; then
  DOCFILE="$1"
fi

WGET2=src/wget2
if [ -n "$2" ]; then
  WGET2="$2"
fi

err=0

# won't process these options
excludes="+(--no-quiet|--html-extension)"

for opt in `$WGET2 --help|egrep -o -- '--[a-zA-Z0-9-]+'|sort -u`; do
  # skip if in $excludes
  case $opt in $excludes) continue;; esac

  if ! egrep -q -- " \`$opt(=|\`|\[)" $DOCFILE; then
    # search for the --no- variant
    noopt="--no-`echo $opt|cut -c3-`"
    if ! egrep -q -- " \`$noopt\`" $DOCFILE; then
      echo "Failed to find \`$opt in $DOCFILE"
      err=1
    fi
  fi
done

exit $err