genprotimg/check_hostkeydoc: fix bash detection

We cannot rely on what $SHELL says as it describes what the users
default shell is and not which kind of shell /bin/sh is. So instead of
checking the environment variable $SHELL, we can test whether the
environment variable $BASH is set. If this is the case, we can be
pretty sure that the script is executed by the bash shell.

This fixes the error on Ubuntu 20.04:

./check_hostkeydoc se-certs/host-key.crt se-certs/ibm-z-host-key-signing.crt -c se-certs/DigiCertCA.crt -r se-certs/ibm-z-host-key.crl
./check_hostkeydoc: 42: set: Illegal option -o pipefail

Reviewed-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2020-07-10 21:07:52 +02:00
committed by Jan Höppner
parent 34cfca722c
commit 320e11dcf9

View File

@@ -37,7 +37,7 @@ cleanup()
trap cleanup EXIT
# Enhanced error checking for bash
if echo $SHELL | grep /bin/bash > /dev/null
if [ -n "${BASH}" ]
then
set -o pipefail
set -o nounset