On Wed, Nov 09, 2022 at 12:32:10PM +0000, Alyssa Ross wrote:
@@ -38,7 +39,7 @@ scriptsDir="$(dirname "$0")" out="$1" shift
-nl=$'\n' +nl='\n' table="label: gpt"
# Keep 1MiB free at the start, and 1MiB free at the end. @@ -51,9 +52,7 @@ done
rm -f "$out" truncate -s "$gptBytes" "$out" -sfdisk "$out" <<EOF -$table -EOF +printf "$table" | sfdisk "$out"
The heredoc previously used here should be POSIX:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#ta...
Does it not work in dash?
Heredoc works in dash too, but I couldn't find out how to expand the newlines in variable inside heredoc so that it would work in dash. Therefore I simply removed the heredoc and used printf instead.
I think the problem there is this one:
https://www.shellcheck.net/wiki/SC3003 -- In POSIX sh, $'..' is undefined.
So I think we could fix it without introducing an extra printf process, by changing how we define `nl` to use a literal newline.
The following test script worked for me in dash:
nl=' ' cat <<EOF foo${nl}bar EOF
True, that works fine. Let me fix this with a new version in a moment.