3
0
Fork 0
forked from mirrors/nixpkgs

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
This commit is contained in:
Bjørn Forsman 2013-12-07 21:13:06 +01:00
parent c32bf83301
commit 4e385fcda7

View file

@ -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