File: check_help_option.sh

package info (click to toggle)
cod-tools 3.11.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,136 kB
  • sloc: perl: 58,707; sh: 41,323; ansic: 7,268; xml: 1,982; yacc: 1,117; makefile: 731; python: 166
file content (23 lines) | stat: -rwxr-xr-x 900 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
#!/bin/sh

# This Shell test checks whether all of the scripts in scripts/ accept
# '--help' command line option and prints out some useful information.

#BEGIN DEPEND------------------------------------------------------------------
INPUT_SCRIPTS=$(find scripts -maxdepth 1 -name \*~ -prune -o -type f -a -executable -print | sort | xargs echo)
#END DEPEND--------------------------------------------------------------------

for i in ${INPUT_SCRIPTS}
do
    if ! grep -qlF '#!perl -w # --*- Perl -*--' ./"$i" || perl -c ./"$i" 2>/dev/null
    then
        HELP_MESSAGE=$(./"$i" --help </dev/null)
        if [ -n "${HELP_MESSAGE}" ]
        then
            echo "${HELP_MESSAGE}" | grep -q USAGE || echo "$i: No USAGE section"
            echo "${HELP_MESSAGE}" | grep -q OPTIONS || echo "$i: No OPTIONS section"
        else
            echo "$i: No --help message output"
        fi
    fi
done