paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit b11ba280f423f67b186c847b53e7ee2952ce7642
parent dcdf65683aa5cb5c4b1717ff1e05233edad470c1
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sat, 23 May 2020 23:39:36 -0400

Add newline to sed 'a' commands for FreeBSD

Sed on FreeBSD (and probably the other BSDs too) requires sed 'a'
commands to have a newline before the text to be appended. This is also
supported in GNU sed.

Diffstat:
Mcompile | 18++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/compile b/compile @@ -171,7 +171,8 @@ set_html_csslink() print_info_msg "Adding CSS <link>s" echo "$cssList" | tr ' ' '\n' | while read cssFile; do cssFile="/css/$(echo "$cssFile" | tr -d '"')" - sed -i -e "/<title>/a\ \ \ \ <link rel=\"stylesheet\" href=\"$cssFile\">" \ + sed -i -e "/<title>/a\\ + <link rel=\"stylesheet\" href=\"$cssFile\">" \ "$outputFile" done } @@ -185,9 +186,11 @@ set_html_toc() if [ -z "$tocList" ]; then return 0 fi - sed -i -e "/TOC/a <div id=\"table-of-contents\" aria-label=\"Table of Contents\">\n<h2 id=\"toc-title\">Table of Contents</h2>" \ + sed -i -e "/TOC/a\\ + <div id=\"table-of-contents\" aria-label=\"Table of Contents\">\n<h2 id=\"toc-title\">Table of Contents</h2>" \ "$outputFile" - sed -i -e "/toc-title/a </ul></div>" "$outputFile" + sed -i -e "/toc-title/a\\ + </ul></div>" "$outputFile" echo "$tocList" | tr ';' '\n' \ | awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' \ | while read tocEntry; do @@ -196,7 +199,8 @@ set_html_toc() tocEntry="$(echo "$tocEntry" | cut -d':' -f2-)" tocEntryId="$(echo "$tocEntry" | tr ' ' '-' \ | tr '[:upper:]' '[:lower:]' )" - sed -i -e "/toc-title/a <ul><ul><li><a href=\"#$tocEntryId\">$tocEntry</a></li></ul></ul>" \ + sed -i -e "/toc-title/a\\ + <ul><ul><li><a href=\"#$tocEntryId\">$tocEntry</a></li></ul></ul>" \ "$outputFile" sed -i -e "/<h5>$tocEntry<\/h5>/i </section>\n<section>" \ "$outputFile" @@ -204,14 +208,16 @@ set_html_toc() tocEntry="$(echo "$tocEntry" | cut -d':' -f2-)" tocEntryId="$(echo "$tocEntry" | tr ' ' '-' \ | tr '[:upper:]' '[:lower:]' )" - sed -i -e "/toc-title/a <ul><li><a href=\"#$tocEntryId\">$tocEntry</a></li></ul>" \ + sed -i -e "/toc-title/a\\ + <ul><li><a href=\"#$tocEntryId\">$tocEntry</a></li></ul>" \ "$outputFile" sed -i -e "/<h4>$tocEntry<\/h4>/i </section>\n<section>" \ "$outputFile" else tocEntryId="$(echo "$tocEntry" | tr ' ' '-' \ | tr '[:upper:]' '[:lower:]' )" - sed -i -e "/toc-title/a <li><a href=\"#$tocEntryId\">$tocEntry</a></li>" \ + sed -i -e "/toc-title/a\\ + <li><a href=\"#$tocEntryId\">$tocEntry</a></li>" \ "$outputFile" sed -i -e "/<h3>$tocEntry<\/h3>/i </section\>\n<section>" \ "$outputFile"