mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 21:21:06 +00:00
stdenv/setup.sh: fix breakage when shebang contains '\'
Some programs, e.g. guile-config, has a shebang that ends in '\': #!/usr/bin/guile-1.8 \ -e main -s !# ;;;; guile-config --- utility for linking programs with Guile ;;;; Jim Blandy <jim@red-bean.com> --- September 1997 This currently breaks patchShebangs: $ read oldPath arg0 args <<< 'shebang \'; echo $? 1 $ echo $oldPath shebang $ echo $arg0 $ echo $args (And setup.sh/patchShebangs is run with 'set -e' so any command that return non-zero aborts the build.) Fix by telling 'read' to not interpret backslashes (with the -r flag): $ read -r oldPath arg0 args <<< 'shebang \'; echo $? 0 $ echo $oldPath shebang $ echo $arg0 \ $ echo $args Also needed: escape the escape characters so that sed doesn't interpret them.
This commit is contained in:
parent
86802e68ff
commit
f4f0d2ecb9
|
@ -677,7 +677,7 @@ patchShebangs() {
|
|||
fi
|
||||
|
||||
oldInterpreterLine=$(head -1 "$f" | tail -c +3)
|
||||
read oldPath arg0 args <<< "$oldInterpreterLine"
|
||||
read -r oldPath arg0 args <<< "$oldInterpreterLine"
|
||||
|
||||
if $(echo "$oldPath" | grep -q "/bin/env$"); then
|
||||
# Check for unsupported 'env' functionality:
|
||||
|
@ -703,7 +703,9 @@ patchShebangs() {
|
|||
if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then
|
||||
if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then
|
||||
echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
|
||||
sed -i -e "1 s|.*|#\!$newInterpreterLine|" "$f"
|
||||
# escape the escape chars so that sed doesn't interpret them
|
||||
escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
|
||||
sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue