]> git.plutz.net Git - lobster/blobdiff - pdiread.sh
Merge commit 'a27498203e5d589514f082a0fcdcca53e31c595e' into cgilite
[lobster] / pdiread.sh
index 49c2c20d88a7baca7754b0bde5d96482dbe4f3f8..58baa88dac998826f5bb886b882bb322839a9459 100755 (executable)
@@ -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"
 }