X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=pdiread.sh;h=08fbaec3fb373c2fbb6cdde7974caaa520b849e3;hp=6f15658dc912c72a187c1559328e1e77a763b741;hb=HEAD;hpb=1b60162cdd40f964fed3d943d95601f42479b5de diff --git a/pdiread.sh b/pdiread.sh index 6f15658..e19ceb8 100755 --- a/pdiread.sh +++ b/pdiread.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 - 2018 Paul Hänsch +# Copyright 2014 - 2018, 2023 Paul Hänsch # # This file is part of Confetti. # @@ -25,6 +25,17 @@ include_pdi="$0" BR=' ' +unescape(){ + local in out='' + [ $# -gt 0 ] && in="$*" || in="$(cat)" + while [ "$in" ]; do case $in in + \\\\*) out="${out}\\"; in="${in#\\\\}" ;; + \\n*) out="${out}${BR}"; in="${in#\\n}" ;; + \\*) in="${in#\\}" ;; + *) out="${out}${in%%[\\]*}"; in="${in#"${in%%[\\]*}"}" ;; + esac; done + printf '%s\n' "$out" + } pdi_load() { # normalise PDI file for processing with pdi_* functions