From ca3ecb56ae5a0a5b675ebecdb819a0b97c547df0 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 9 Oct 2014 23:14:17 +0400 Subject: [PATCH] stdenv: change 'echo -n' to 'printf "%s"' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Bjørn: rationale is portability, "echo -n" isn't in POSIX] --- pkgs/stdenv/generic/setup.sh | 7 +++---- 1 file 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" }