Explorar o código

Be more careful about embedded newlines

John Tyree %!s(int64=11) %!d(string=hai) anos
pai
achega
b6821e3aa0
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      append_output.sh

+ 5 - 1
append_output.sh

@@ -5,4 +5,8 @@ set -e
 src=$(sed -n -e "0,/### OUTPUT ###/p" "$1")
 output=$(python "$1" | sed 's/^/# /')
 
-echo -e "${src}\n${output}" > "$1"
+# These are done separately to avoid having to insert a newline, which causes
+# problems when the text itself has '\n' in strings
+echo "$src" > $1
+echo -e "\n### OUTPUT ###" >> $1
+echo "$output" >> $1