about summary refs log tree commit diff
path: root/pkgs/stdenv/generic/setup.sh
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2014-10-09 23:14:17 +0400
committerBjørn Forsman <bjorn.forsman@gmail.com>2014-10-09 22:15:07 +0200
commitca3ecb56ae5a0a5b675ebecdb819a0b97c547df0 (patch)
treedcfbce8fba98cdf541e149aebc1b673a6aa914d4 /pkgs/stdenv/generic/setup.sh
parent2ec4704961bc12bab1ba1a5af05f21d2dcc91e7d (diff)
downloadnixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.tar
nixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.tar.gz
nixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.tar.bz2
nixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.tar.lz
nixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.tar.xz
nixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.tar.zst
nixlib-ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0.zip
stdenv: change 'echo -n' to 'printf "%s"'
[Bjørn: rationale is portability, "echo -n" isn't in POSIX]
Diffstat (limited to 'pkgs/stdenv/generic/setup.sh')
-rw-r--r--pkgs/stdenv/generic/setup.sh7
1 files changed, 3 insertions, 4 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index eba29beee172..03859f3ba8af 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -101,7 +101,7 @@ exitHandler() {
         if [ -n "$succeedOnFailure" ]; then
             echo "build failed with exit code $exitCode (ignored)"
             mkdir -p "$out/nix-support"
-            echo -n $exitCode > "$out/nix-support/failed"
+            printf "%s" $exitCode > "$out/nix-support/failed"
             exit 0
         fi
 
@@ -339,7 +339,7 @@ substitute() {
     local n p pattern replacement varName content
 
     # a slightly hacky way to keep newline at the end
-    content="$(cat "$input"; echo -n X)"
+    content="$(cat "$input"; printf "%s" X)"
     content="${content%X}"
 
     for ((n = 2; n < ${#params[*]}; n += 1)); do
@@ -367,8 +367,7 @@ substitute() {
         content="${content//"$pattern"/$replacement}"
     done
 
-    # !!! This doesn't work properly if $content is "-n".
-    echo -n "$content" > "$output".tmp
+    printf "%s" "$content" > "$output".tmp
     if [ -x "$output" ]; then chmod +x "$output".tmp; fi
     mv -f "$output".tmp "$output"
 }