`make tlok` outputs "FAIL\n" if the executable wasn't created
[sunny256-utils.git] / Lib / std / bisect
blob698e7e2d84232056b8bdcc11f59038ad6c7d40c2
1 #!/usr/bin/env bash
3 #=======================================================================
4 # STDfilenameDTS
5 # File ID: STDuuidDTS
7 # [Description]
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
13 progname=STDfilenameDTS
14 VERSION=0.0.0
16 ARGS="$(getopt -o "\
20 " -l "\
21 help,\
22 quiet,\
23 verbose,\
24 version,\
25 " -n "$progname" -- "$@")"
26 test "$?" = "0" || exit 1
27 eval set -- "$ARGS"
29 opt_help=0
30 opt_quiet=0
31 opt_verbose=0
32 while :; do
33 case "$1" in
34 -h|--help) opt_help=1; shift ;;
35 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
36 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
37 --version) echo $progname $VERSION; exit 0 ;;
38 --) shift; break ;;
39 *) echo $progname: Internal error >&2; exit 1 ;;
40 esac
41 done
42 opt_verbose=$(($opt_verbose - $opt_quiet))
44 if test "$opt_help" = "1"; then
45 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
46 cat <<END
48 Usage: $progname [options]
50 Options:
52 -h, --help
53 Show this help.
54 -q, --quiet
55 Be more quiet. Can be repeated to increase silence.
56 -v, --verbose
57 Increase level of verbosity. Can be repeated.
58 --version
59 Print version information.
61 END
62 exit 0
65 topdir=/home/directory_that_does_not_exist-STDuuidDTS
67 # What the STDfilenameDTS script shall return, switch the values if the test
68 # returns 0 for error and !0 for success.
69 good=0
70 bad=1
72 function cleangit {
73 cd $topdir || {
74 echo "STDfilenameDTS: $topdir: Cannot change directory, aborting." >&2
75 exit 150
77 if [ ! -d .git/. ]; then
78 echo -n "STDfilenameDTS: $topdir: " >&2
79 echo "Doesn’t contain a .git directory, aborting." >&2
80 exit 150
82 git clean -fxd
83 git co -f
86 function inittest {
87 : Things like ./configure and make goes here
90 function runtest {
91 : The actual test goes here and should return !$good on error
94 cleangit
95 cd $topdir
96 inittest
97 runtest || { echo STDfilenameDTS: bad, returns $bad; exit $bad; }
98 echo STDfilenameDTS: good, returns $good
99 exit $good