diff mbox

support: properly check bash is available

Message ID 1395185629-728-1-git-send-email-yann.morin.1998@free.fr
State Accepted
Headers show

Commit Message

Yann E. MORIN March 18, 2014, 11:33 p.m. UTC
From: "Yann E. MORIN" <yann.morin.1998@free.fr>

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!)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <jacmet@uclibc.org>
Cc: Andrew Barnes <andy@outsideglobe.com>
---
 support/dependencies/dependencies.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Thomas Petazzoni April 20, 2014, 9:14 a.m. UTC | #1
Dear Yann E. MORIN,

On Wed, 19 Mar 2014 00:33:49 +0100, Yann E. MORIN wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> 
> 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!)
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Peter Korsgaard <jacmet@uclibc.org>
> Cc: Andrew Barnes <andy@outsideglobe.com>
> ---
>  support/dependencies/dependencies.sh | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

Applied, thanks.

Thomas
diff mbox

Patch

diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh
index a8261b3..0566814 100755
--- a/support/dependencies/dependencies.sh
+++ b/support/dependencies/dependencies.sh
@@ -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"