aboutsummaryrefslogtreecommitdiff
path: root/src/wrappers/postopts.sh
blob: e0d015f416a21a6009c78ea6e62792e8c43c7a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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"