From 4e385fcda73dd437152d42aefdde4bcb79d23c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Sat, 7 Dec 2013 21:13:06 +0100 Subject: [PATCH] stdenv/patchShebangs: fix shebang check patchShebangs has a bug that shows itself on files that have the executable bit set but have no shebang (i.e. a blank/empty first line). The shell would then evaluate this: if [ != '#!' ]; then # not evaluated fi With proper quoting we get the correct behaviour: if [ "" != '#!' ]; then # this will be evaluated fi --- pkgs/stdenv/generic/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 1ed905db363..84d499696c9 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -669,7 +669,7 @@ patchShebangs() { local newInterpreterLine for f in $(find "$dir" -type f -perm +0100); do - if [ $(head -1 "$f" | head -c +2) != '#!' ]; then + if [ "$(head -1 "$f" | head -c +2)" != '#!' ]; then # missing shebang => not a script continue fi