paritybit.ca

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

commit cc66526f5d01cc1d47086690b45419eb27f81c2e
parent d7307dac3cae758ae272031b3fc90987816b6896
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sat, 23 May 2020 16:44:27 -0400

Add -e flag to sed commands

Necessary to make it work on FreeBSD.

Diffstat:
Mcompile | 42+++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/compile b/compile @@ -151,28 +151,28 @@ compile_md() set_html_title() { - title=$(head -n1 $file | cut -d' ' -f2-) + title="$(head -n1 "$file" | cut -d' ' -f2-)" print_info_msg "Setting <title>: \"$title\"" - sed -i "s/<title>.*<\/title>/<title>$title - $siteName<\/title>/" \ + sed -i -e "s/<title>.*<\/title>/<title>$title - $siteName<\/title>/" \ "$outputFile" } set_html_meta() { - meta=$(head -n3 $file | tail -n1 \ - | cut -d'#' -f2 | sed -e 's/^[[:space:]]*//') + meta="$(head -n3 "$file" | tail -n1 \ + | cut -d'#' -f2 | sed -e 's/^[[:space:]]*//')" print_info_msg "Setting <meta> description" - sed -i "s/content=\"\"/content=$meta/" "$outputFile" + sed -i -e "s/content=\"\"/content=$meta/" "$outputFile" } set_html_csslink() { - cssList=$(head -n5 $file | tail -n1 \ - | cut -d'#' -f2 | sed -e 's/^[[:space:]]*//') + cssList="$(head -n5 "$file" | tail -n1 \ + | cut -d'#' -f2 | sed -e 's/^[[:space:]]*//')" print_info_msg "Adding CSS <link>s" echo "$cssList" | tr ' ' '\n' | while read cssFile; do cssFile="/css/$(echo "$cssFile" | tr -d '"')" - sed -i "/<title>/a\ \ \ \ <link rel=\"stylesheet\" href=\"$cssFile\">" \ + sed -i -e "/<title>/a\ \ \ \ <link rel=\"stylesheet\" href=\"$cssFile\">" \ "$outputFile" done } @@ -180,15 +180,15 @@ set_html_csslink() # This still feels a bit messy set_html_toc() { - tocList=$(head -n7 $file | tail -n1 \ - | cut -d'#' -f2 | sed -e 's/^[[:space:]]*//' | tr -d '"') + tocList="$(head -n7 "$file" | tail -n1 \ + | cut -d'#' -f2 | sed -e 's/^[[:space:]]*//' | tr -d '"')" print_info_msg "Adding Table of Contents" if [ -z "$tocList" ]; then return 0 fi - sed -i "/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 "/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 @@ -197,30 +197,30 @@ set_html_toc() tocEntry="$(echo "$tocEntry" | cut -d':' -f2-)" tocEntryId="$(echo "$tocEntry" | tr ' ' '-' \ | tr '[:upper:]' '[:lower:]' )" - sed -i "/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 "/<h5>$tocEntry<\/h5>/i </section>\n<section>" \ + sed -i -e "/<h5>$tocEntry<\/h5>/i </section>\n<section>" \ "$outputFile" elif echo "$tocEntry" | grep -qi "^sub:"; then tocEntry="$(echo "$tocEntry" | cut -d':' -f2-)" tocEntryId="$(echo "$tocEntry" | tr ' ' '-' \ | tr '[:upper:]' '[:lower:]' )" - sed -i "/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 "/<h4>$tocEntry<\/h4>/i </section>\n<section>" \ + sed -i -e "/<h4>$tocEntry<\/h4>/i </section>\n<section>" \ "$outputFile" else tocEntryId="$(echo "$tocEntry" | tr ' ' '-' \ | tr '[:upper:]' '[:lower:]' )" - sed -i "/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 "/<h3>$tocEntry<\/h3>/i </section\>\n<section>" \ + sed -i -e "/<h3>$tocEntry<\/h3>/i </section\>\n<section>" \ "$outputFile" fi done - sed -i "/toc-title/a <ul>" "$outputFile" - sed -i "/END OF HEADER FILE/a <section>" "$outputFile" - sed -i "/<\/main>/i </section>" "$outputFile" + sed -i -e "/toc-title/a <ul>" "$outputFile" + sed -i -e "/END OF HEADER FILE/a <section>" "$outputFile" + sed -i -e "/<\/main>/i </section>" "$outputFile" } for file in "$@"; do