aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWynn Wolf Arbor2020-05-12 22:14:47 +0200
committerWynn Wolf Arbor2020-05-16 10:55:38 +0200
commite25e7ad50bb82b416e2c703356867a8be7cb9d09 (patch)
tree58f72fe23e9e88ef79cb01e27d12444db8e7ff3d
parent363ef24cbdff39adefe983ccf783e1c867819b93 (diff)
downloadkern-e25e7ad50bb82b416e2c703356867a8be7cb9d09.tar.gz
Simplify conditional logic in test_diff()
Previously we recorded the return value of the sed ... | diff pipeline into a variable and later used it to test whether the command returned successfully or not. Since we enable errexit, this meant that the diff command failing would terminate the execution of the whole script. We are unsure how this was not caught earlier as the script has been in use for quite a while now - it is possible that bash 5.0 shows different behaviour here. It is our understanding that bash's current behaviour is correct, however. Instead of using a variable to store the return value, put the whole pipeline into an if clause, and react to its success or failure there. Whilst this does remove our ability to indicate diff's actual return value, it makes this test simpler and more straightforward.
-rwxr-xr-xkern12
1 files changed, 5 insertions, 7 deletions
diff --git a/kern b/kern
index 9686e57..f4a8be3 100755
--- a/kern
+++ b/kern
@@ -85,18 +85,16 @@ clean_kernel() {
test_diff() {
dt=$(mktemp)
zcat /proc/config.gz | sed -nE '/^(# )?CONFIG_.*/p' > "$dt"
- sed -nE '/^(# )?CONFIG_.*/p' .config | diff -q "$dt" -
- diffr=$?
- rm -f "$dt"
- if test $diffr -ne 0; then
+ if ! sed -nE '/^(# )?CONFIG_.*/p' .config | diff -q "$dt" -; then
diff_kernel
printf "Continue? [y/N] "
read -r response
- if test "$response" = "y"; then
- return 0
+ if test "$response" != "y"; then
+ rm "$dt"
+ return 1
fi
fi
- return $diffr
+ rm "$dt"
}
all() {