Make sure all scripts are set -e
If scripts are not set -e then errors can be ignored, causing more confusing failures later. Also adds an exclusion comment to the ramdisk init script since we don't want that to exit on failure. Change-Id: Idf43993bd10b1ef16c1d3b0d9df8d0ad94c46458
This commit is contained in:
parent
825b1964bb
commit
79ab95b16e
23
bin/dib-lint
23
bin/dib-lint
@ -18,6 +18,9 @@
|
||||
# This script checks all files in the "elements" directory for some
|
||||
# common mistakes and exits with a non-zero status if it finds any.
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
parse_exclusions() {
|
||||
# Exclusions are currently only read on a per-file basis
|
||||
local filename=$1
|
||||
@ -62,5 +65,23 @@ for i in $(find elements -type f); do
|
||||
rc=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check that all scripts are set -e
|
||||
# NOTE(bnemec): This doesn't verify that the set call occurs high
|
||||
# enough in the file to be useful, but hopefully nobody will be
|
||||
# sticking set calls at the end of their file to trick us. And if
|
||||
# they are, that's easy enough to catch in reviews.
|
||||
# Also, this is only going to check bash scripts - we've decided to
|
||||
# explicitly require bash for any scripts that don't have a specific
|
||||
# need to run under other shells, and any exceptions to that rule
|
||||
# may not want these checks either.
|
||||
if [ -n "$(echo $firstline | grep '#!/bin/bash')" ]; then
|
||||
if ! excluded sete; then
|
||||
if [ -z "$(grep "^set -[^ ]*e" $i)" ]; then
|
||||
echo "ERROR: $i is not set -e"
|
||||
rc=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
exit $rc
|
||||
exit $rc
|
||||
|
@ -16,6 +16,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# NOTE(bnemec): We don't want this script to exit on failures because if init
|
||||
# dies then we get a kernel panic on ramdisk boot.
|
||||
# dib-lint: disable=sete setu setpipefail
|
||||
|
||||
echo "init"
|
||||
|
||||
source /init-func
|
||||
|
Loading…
Reference in New Issue
Block a user