Skip to content

Commit 447350f

Browse files
committed
installer: Do not use echo -e in #!/bin/sh script
ShellCheck correctly warns: In scripts/install-nix-from-closure.sh line 218: echo -e "\nif [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn" ^-- SC3037: In POSIX sh, echo flags are undefined. In scripts/install-nix-from-closure.sh line 229: echo -e "\nif [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn" ^-- SC3037: In POSIX sh, echo flags are undefined. Indeed, this actually breaks on Ubuntu where /bin/sh is dash. Fixes NixOS#5458. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 647baaa commit 447350f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/install-nix-from-closure.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
215215
if [ -w "$fn" ]; then
216216
if ! grep -q "$p" "$fn"; then
217217
echo "modifying $fn..." >&2
218-
echo -e "\nif [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
218+
printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
219219
fi
220220
added=1
221221
break
@@ -226,7 +226,7 @@ if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
226226
if [ -w "$fn" ]; then
227227
if ! grep -q "$p" "$fn"; then
228228
echo "modifying $fn..." >&2
229-
echo -e "\nif [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
229+
printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
230230
fi
231231
added=1
232232
break

0 commit comments

Comments
 (0)