X-Git-Url: https://plomlompom.com/repos/?p=redo-blog;a=blobdiff_plain;f=processor%2Fhelpers.sh;h=2869a29a3d414db7066c71e17ff1439b0b7c6c92;hp=20905ab6a9e5f06eb01763088ad2e4310784fabb;hb=6b5631096b03f1c985bc40c4d2e244315280c686;hpb=f88948caf952c4fd913ea7466c2f1ab3455af506 diff --git a/processor/helpers.sh b/processor/helpers.sh index 20905ab..2869a29 100644 --- a/processor/helpers.sh +++ b/processor/helpers.sh @@ -23,7 +23,7 @@ get_basepath() { url_basepath=`echo $base_url | cut -d '/' -f 3-` url_basepath_escaped=`escape_url "$url_basepath"` basepath="$url_protocol""://""$url_basepath_escaped" - echo "$basepath" + printf "%s" "$basepath" } get_source_file() { @@ -37,5 +37,15 @@ get_source_file() { exit 1 fi redo-ifchange "$src_file" - printf "$src_file" + printf "%s" "$src_file" +} + +prep_sed () { + # Escape characters that confuse sed in a replacement string. Also replace + # occurences of % (which the templating uses as a variable marker) with + # non-printable placeholder \a (clear input of it first), to be replaced by + # % again when the templating has finished (so that no replacement string gets + # interpreted by the templating). + sedsafe_pattern='s/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g; $!s/$/\\/g; ' + sed "$sedsafe_pattern" | tr -d '\a' | tr '%' '\a' }