aboutsummaryrefslogtreecommitdiff
path: root/src/wrappers/postopts.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/wrappers/postopts.sh')
-rw-r--r--src/wrappers/postopts.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wrappers/postopts.sh b/src/wrappers/postopts.sh
new file mode 100644
index 000000000..e0d015f41
--- /dev/null
+++ b/src/wrappers/postopts.sh
@@ -0,0 +1,17 @@
+# Parse wrapper and wrappee (pandoc) arguments by taking
+# into account that they may have space or tab characters.
+pick="WRAPPER_ARGS"
+while [ $# -gt 0 ]; do
+ if [ "$pick" = "WRAPPER_ARGS" ]; then
+ case "$1" in
+ -*) pick="WRAPPEE_ARGS" ;;
+ esac
+ fi
+ # Pack args with NEWLINE to preserve spaces,
+ # and put them into the picked variable.
+ eval "$pick=\"\$${pick}${NEWLINE}${1}\""
+ shift
+done
+
+# Unpack filename arguments. Now "$@" will hold the filenames.
+oldifs="$IFS"; IFS="$NEWLINE"; set -- $WRAPPER_ARGS; IFS="$oldifs"