1 # $NetBSD: check-subr.sh,v 1.4 2006/11/11 23:08:00 rillig Exp $
3 # This file contains shell functions that are used by the various shell
4 # programs that check things in pkgsrc. All these programs must be
5 # called with the following environment variables set:
8 # A shell expression of the form
10 # */pattern.*) continue;; *.txt) continue;;
12 # that can be passed to eval(1) in order to skip the files
13 # that are chosen by the respective *_SKIP variable in
17 # Implementation notes:
19 # 1. The SKIP_FILTER variable should only be used in the following
20 # pattern, usually inside a "for" or "while" loop.
23 # eval "case \"\$fname\" in $SKIP_FILTER *.orig) skip=yes;; esac"
24 # [ $skip = no ] || continue
26 # 2. The programs using this file are run with the tools wrapper
27 # directory in the PATH, so they call the utilities by their base names.
28 # They may also assume to be interpreted by a POSIX-conforming shell, in
29 # particular _not_ by the Solaris /bin/sh.
32 # All programs that check something are very strict.
37 # usage: cs_setprogname "progname"
39 # This function sets the variable that will later be used in diagnostic
40 # messages to identify the program that generated the message.
42 cs_progname
="${1##*/}"
45 # Each diagnostic message can be preceded by a heading to better identify
46 # messages that belong together. The heading will only be printed if it
47 # differs from the last one.
50 # usage: cs_error_heading "new heading"
52 if [ x
"$1" != x
"$cs_last_heading" ]; then
58 # usage: cs_warning_heading "new heading"
59 cs_warning_heading
() {
60 if [ x
"$1" != x
"$cs_last_heading" ]; then
62 cs_warning_msg
"=> $1"
66 # usage: cs_error_msg "error message"
68 echo "ERROR: [$cs_progname] $*" 1>&2
72 # usage: cs_warning_msg "warning message"
74 echo "WARNING: [$cs_progname] $*" 1>&2
78 "==========================================================================="
80 # usage: cs_explain <<EOF
93 # At the end of the program, cs_exit should be called to return the
94 # appropriate exit status to the calling process. It is non-zero when
95 # any error messages have been printed and zero otherwise.