X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=pdiread.sh;h=8118318d3d4bdd4e2793d468c037b28b5006588f;hp=6f15658dc912c72a187c1559328e1e77a763b741;hb=refs%2Fheads%2Fcgilite;hpb=1b60162cdd40f964fed3d943d95601f42479b5de diff --git a/pdiread.sh b/pdiread.sh index 6f15658..08fbaec 100755 --- a/pdiread.sh +++ b/pdiread.sh @@ -26,6 +26,16 @@ include_pdi="$0" BR=' ' +unescape() { + local unescape='s;(^(\\\\)*|[^\\](\\\\)*)\\n;\1\n;g; s;\\(.);\1;g' + if [ $# -eq 0 ]; then + sed -E "$unescape" + else + printf %s "$*" \ + | sed -E "$unescape" + fi +} + pdi_load() { # normalise PDI file for processing with pdi_* functions # functions in this library can only be applied to normalised data