Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support: properly check for bash as a dependency
@ 2014-03-17 10:42 Yann E. MORIN
  2014-03-17 21:28 ` Peter Korsgaard
  2014-03-18  5:01 ` Thomas Petazzoni
  0 siblings, 2 replies; 8+ messages in thread
From: Yann E. MORIN @ 2014-03-17 10:42 UTC (permalink / raw)
  To: buildroot

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

The way we are checking for bash is to look if "$SHELL --version"
will return a string containing "^GNU bash".

In case the system shell is dash (eg. /bin/sh -> /bin/dash), but
the user's login shell is bash, dash will not override the SHELL
variable:

    $ echo $SHELL
    /bin/bash
    $ /bin/dash
    $$ echo $SHELL
    /bin/bash

The same happens when called as the interpreter for a shell script:

    $ cat foo.sh
    #!/bin/dash
    echo $SHELL

    $ echo $SHELL
    /bin/bash
    $ ./foo.sh
    /bin/bash

So, calling "$SHELL --version" will still return "^GNU bash" no matter
what shell is actually running.

Since quite a lot of #!/bin/sh scripts are in fact bash scripts, we
really want to ensure that /bin/sh is bash.

Reported-by: Andrew Barnes <andy@outsideglobe.com> (on IRC)
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Andrew Barnes <andy@outsideglobe.com>
---
 support/dependencies/dependencies.sh | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh
index a8261b3..1b1a825 100755
--- a/support/dependencies/dependencies.sh
+++ b/support/dependencies/dependencies.sh
@@ -138,11 +138,16 @@ if [ ! -z "$CXXCOMPILER" ] ; then
 	fi
 fi
 
-# Check bash
-if ! $SHELL --version 2>&1 | grep -q '^GNU bash'; then
+# Check bash is the system shell
+if ! /bin/sh --version 2>&1 | grep -q '^GNU bash'; then
 	echo
-	echo "You must install 'bash' on your build machine";
-	exit 1;
+	echo "You must install 'bash' on your build machine"
+	echo "and make it your default shell. On Debian-like"
+	echo "systems, this can be done with:"
+	echo "    sudo dpkg-reconfigure dash"
+	echo "and answer 'No' to the question:"
+	echo "    Use dash as the default system shell (/bin/sh)?"
+	exit 1
 fi;
 
 # Check that a few mandatory programs are installed
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-20 20:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-17 10:42 [Buildroot] [PATCH] support: properly check for bash as a dependency Yann E. MORIN
2014-03-17 21:28 ` Peter Korsgaard
2014-03-17 21:36   ` Yann E. MORIN
2014-03-17 22:01     ` Peter Korsgaard
2014-03-18  5:01 ` Thomas Petazzoni
2014-03-18 16:55   ` Yann E. MORIN
2014-03-18 18:27     ` Thomas Petazzoni
2014-03-20 20:43     ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox