X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=pdiread.sh;h=58baa88dac998826f5bb886b882bb322839a9459;hb=b67065bfb57b072dd1c344eedabfbb545eae6629;hp=49c2c20d88a7baca7754b0bde5d96482dbe4f3f8;hpb=7aab9839b794a48adaf4b3049fc0b8a999d925f8;p=lobster diff --git a/pdiread.sh b/pdiread.sh index 49c2c20..58baa88 100755 --- a/pdiread.sh +++ b/pdiread.sh @@ -32,7 +32,7 @@ pdi_load() { # Usage example: # data="$(pdi_load file.vcf)" - sed -En ' + sed -srn ' # === Read entire file into buffer === :X $bY; N; bX; :Y s;^.*$;\n&\n;; @@ -100,7 +100,7 @@ pdi_load() { # === Update obsolete LABEL property === s;\nLABEL((\;[A-Za-z0-9-]+|\;[A-Za-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):(.*)\n;\nADR\1\;LABEL="\5":\n;g; - p;' "$1" + p;' "$@" } pdi_escape(){ @@ -112,7 +112,7 @@ pdi_escape(){ ,*) out="${out}\\,"; in="${in#,}" ;; \;*) out="${out}\\;"; in="${in#;}" ;; "$BR"*) out="${out}\\n"; in="${in#${BR}}" ;; - *) out="${out}${in%%[\\,;${BR}]*}"; in="${in#${in%%[\\,;${BR}]*}}" ;; + *) out="${out}${in%%[\\,;${BR}]*}"; in="${in#"${in%%[\\,;${BR}]*}"}" ;; esac; done done printf '%s\n' "$out" @@ -125,7 +125,7 @@ pdi_unescape(){ \\\\*) out="${out}\\"; in="${in#\\\\}" ;; \\n*) out="${out}${BR}"; in="${in#\\n}" ;; \\*) in="${in#\\}" ;; - *) out="${out}${in%%\\*}"; in="${in#${in%%\\*}}" ;; + *) out="${out}${in%%\\*}"; in="${in#"${in%%\\*}"}" ;; esac; done printf '%s\n' "$out" }