stdenv: change 'echo -n' to 'printf "%s"'

[Bjørn: rationale is portability, "echo -n" isn't in POSIX]
This commit is contained in:
Nikolay Amiantov 2014-10-09 23:14:17 +04:00 committed by Bjørn Forsman
parent 2ec4704961
commit ca3ecb56ae

View File

@ -101,7 +101,7 @@ exitHandler() {
if [ -n "$succeedOnFailure" ]; then if [ -n "$succeedOnFailure" ]; then
echo "build failed with exit code $exitCode (ignored)" echo "build failed with exit code $exitCode (ignored)"
mkdir -p "$out/nix-support" mkdir -p "$out/nix-support"
echo -n $exitCode > "$out/nix-support/failed" printf "%s" $exitCode > "$out/nix-support/failed"
exit 0 exit 0
fi fi
@ -339,7 +339,7 @@ substitute() {
local n p pattern replacement varName content local n p pattern replacement varName content
# a slightly hacky way to keep newline at the end # 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}" content="${content%X}"
for ((n = 2; n < ${#params[*]}; n += 1)); do for ((n = 2; n < ${#params[*]}; n += 1)); do
@ -367,8 +367,7 @@ substitute() {
content="${content//"$pattern"/$replacement}" content="${content//"$pattern"/$replacement}"
done done
# !!! This doesn't work properly if $content is "-n". printf "%s" "$content" > "$output".tmp
echo -n "$content" > "$output".tmp
if [ -x "$output" ]; then chmod +x "$output".tmp; fi if [ -x "$output" ]; then chmod +x "$output".tmp; fi
mv -f "$output".tmp "$output" mv -f "$output".tmp "$output"
} }