]> git.plutz.net Git - lobster/commitdiff
introduced general pdi unescape function
authorPaul Hänsch <paul@plutz.net>
Wed, 20 Jan 2021 23:39:15 +0000 (00:39 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 20 Jan 2021 23:39:15 +0000 (00:39 +0100)
cards/index.cgi
courses/index.cgi
pdiread.sh

index f1306f6aeb0ed05f395a2580fed9fe2f85b62a7e..90be142e631be5632667aaa10cc0d28e24a8fabc 100755 (executable)
@@ -11,7 +11,6 @@ fi
 . $_EXEC/cards/widgets.sh
 . $_EXEC/cards/list.sh
 
-unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; }
 upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; '
 
 filter="$(GET f)"
index 56db2faa7ef9731f2c97d489484ef16849b8d976..e98d7b6aeadf4bcb7dcfa84202ddb0303caa73ce 100755 (executable)
@@ -11,7 +11,6 @@ fi
 . $_EXEC/courses/widgets.sh
 . $_EXEC/courses/list.sh
 
-unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; }
 upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; '
 
 order="$(GET o |grep -m1 -xE 'DOW|TOD')"
index 6f15658dc912c72a187c1559328e1e77a763b741..08fbaec3fb373c2fbb6cdde7974caaa520b849e3 100755 (executable)
@@ -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