diff options
author | Runxi Yu <me@runxiyu.org> | 2024-07-08 08:00:00 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2024-07-08 08:00:00 +0800 |
commit | c4f0c644fd2d43cfb3c244a11c1afc94341384c4 (patch) | |
tree | a2e7bad0276748f05cd13a541f0e209cd32db7d5 | |
parent | Allow specifying output filename as the first argument (diff) | |
download | websvgtex-master.tar.gz websvgtex-master.zip |
-rwxr-xr-x | websvgtex | 36 |
1 files changed, 10 insertions, 26 deletions
@@ -1,29 +1,13 @@ #!/bin/sh -err() { - { set +x; } 2>/dev/null - echo "$@" >&2 - exit 1 -} - -ensure_noset() { - [ $# -lt 1 ] && return 0 - $@ || err failed executing: "$@" -} - -ensure() { - { set +x; } 2>/dev/null - [ $# -lt 1 ] && return 0 - $@ || err failed executing: "$@" - { set -x; } 2>/dev/null -} +set -eux rxrand="$(base64 < /dev/random | tr -d '/+=' | head -c 10)" opwd="$(pwd)" -ensure_noset mkdir /tmp/websvgtex-$rxrand -ensure_noset cd /tmp/websvgtex-$rxrand +mkdir /tmp/websvgtex-$rxrand +cd /tmp/websvgtex-$rxrand cat >m.tex <<EOF \documentclass[preview]{standalone} @@ -37,18 +21,18 @@ cat >>m.tex <<EOF \end{document} EOF +{ set +u; } 2>/dev/null if [ -z "$1" ] then export_filename="m.svg" else export_filename="$1" fi +{ set -u; } 2>/dev/null -{ set -x; } 2>/dev/null +latex m.tex +latex m.tex +dvips m.dvi +inkscape m.ps --export-plain-svg --export-filename="$export_filename" -ensure latex m.tex -ensure latex m.tex -ensure dvips m.dvi -ensure inkscape m.ps --export-plain-svg --export-filename="$export_filename" - -ensure mv "$export_filename" "$opwd" +mv "$export_filename" "$opwd" |