2021-12-12 22:27:04 +03:00
#!/usr/bin/env bash
2021-01-27 15:37:10 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2017-12-24 09:53:20 +03:00
set -eu
2021-04-20 14:02:02 +03:00
set -o pipefail
2017-04-13 18:52:05 +03:00
2021-04-20 14:02:02 +03:00
# Note: `grep ... >/dev/null` instead of just `grep -q` is used intentionally
# here, since `grep -q` exits on the first match causing SIGPIPE being
# sent to the sender.
BINARY = " ${ 1 : ? } "
2017-11-25 18:01:55 +03:00
export SYSTEMD_LOG_LEVEL = info
2021-04-20 14:02:02 +03:00
if [ [ ! -x " $BINARY " ] ] ; then
echo " $BINARY is not an executable "
exit 1
fi
2017-04-13 18:52:05 +03:00
# output width
2021-04-20 14:02:02 +03:00
if " $BINARY " --help | grep -v 'default:' | grep -E '.{80}.' >/dev/null; then
echo " $( basename " $BINARY " ) --help output is too wide: "
" $BINARY " --help | awk 'length > 80' | grep -E --color= yes '.{80}'
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
exit 1
2017-04-13 18:52:05 +03:00
fi
2019-07-22 11:59:19 +03:00
# --help prints something. Also catches case where args are ignored.
2021-04-20 14:02:02 +03:00
if ! " $BINARY " --help | grep . >/dev/null; then
echo " $( basename " $BINARY " ) --help output is empty. "
2019-07-22 11:59:19 +03:00
exit 2
fi
2017-04-13 18:52:05 +03:00
# no --help output to stdout
2021-04-20 14:02:02 +03:00
if " $BINARY " --help 2>& 1 1>/dev/null | grep .; then
echo " $( basename " $BINARY " ) --help prints to stderr "
2019-07-22 11:59:19 +03:00
exit 3
2017-04-13 18:52:05 +03:00
fi
# error output to stderr
2021-04-20 14:02:02 +03:00
if ! ( " $BINARY " --no-such-parameter 2>& 1 1>/dev/null || :) | grep . >/dev/null; then
echo " $( basename " $BINARY " ) with an unknown parameter does not print to stderr "
2019-07-22 11:59:19 +03:00
exit 4
2017-04-13 18:52:05 +03:00
fi