Skip to contentSkip to conversation

support: properly check bash is available

PATCH New Yann E. MORIN 2 participants 2 messages Mar 18, 2014 – Apr 20, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support: properly check bash is available

From: "Yann E. MORIN" <[email protected]>

The current check is broken, as it only checks if the user's login shell is bash, not what the system shell is.

Mimick the sequence found in the top-level Makefile to search for bash, except for the fallback case, where we explicitly check that 'sh' is bash, by checking if it sets $BASH, so we know the fallback case, in the top-level Makefile, to use 'sh' will indeed use bash.

Remove superfluous semi-colons ';' at the end of lines, they are not needed in a shell script (this is not C!)

Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>
Cc Andrew Barnes <[email protected]>
---
 support/dependencies/dependencies.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
support/dependencies/dependencies.sh +8 -4
index a8261b3..0566814 100755
@@ -139,11 +139,15 @@ if [ ! -z "$CXXCOMPILER" ] ; then
 fi
 
 # Check bash
-if ! $SHELL --version 2>&1 | grep -q '^GNU bash'; then
+# We only check bash is available, setting SHELL appropriately is done
+# in the top-level Makefile, and we mimick the same sequence here
+if   [ -n "${BASH}" ]; then :
+elif [ -x /bin/bash ]; then :
+elif [ -z "$( sh -c 'echo $BASH' )" ]; then
 	echo
-	echo "You must install 'bash' on your build machine";
-	exit 1;
-fi;
+	echo "You must install 'bash' on your build machine"
+	exit 1
+fi
 
 # Check that a few mandatory programs are installed
 missing_progs="no"
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/1 support: properly check bash is available

Dear Yann E. MORIN,

Quoted 13 lines · Yann E. MORIN

From: "Yann E. MORIN" <[email protected]>

The current check is broken, as it only checks if the user's login shell is bash, not what the system shell is.

Mimick the sequence found in the top-level Makefile to search for bash, except for the fallback case, where we explicitly check that 'sh' is bash, by checking if it sets $BASH, so we know the fallback case, in the top-level Makefile, to use 'sh' will indeed use bash.

Remove superfluous semi-colons ';' at the end of lines, they are not needed in a shell script (this is not C!)

Quoted 7 lines
Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>
Cc Andrew Barnes <[email protected]>
---
 support/dependencies/dependencies.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com