aboutsummaryrefslogtreecommitdiff
path: root/bin/pst.mi5
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-06-02 22:07:52 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-06-02 22:07:52 +1200
commitbc1d5fb28841f6050605e93886685b3a02e7787a (patch)
treef0f02d8d4884b0864334ad774c98da87c0301379 /bin/pst.mi5
parentCorrect some terms in man mi5(1df) (diff)
downloaddotfiles-bc1d5fb28841f6050605e93886685b3a02e7787a.tar.gz
dotfiles-bc1d5fb28841f6050605e93886685b3a02e7787a.zip
Use mi5 to make templated shell scripts
Diffstat (limited to 'bin/pst.mi5')
-rw-r--r--bin/pst.mi519
1 files changed, 19 insertions, 0 deletions
diff --git a/bin/pst.mi5 b/bin/pst.mi5
new file mode 100644
index 00000000..34ffbd8c
--- /dev/null
+++ b/bin/pst.mi5
@@ -0,0 +1,19 @@
+# Interrupt a pipe with manual /dev/tty input to a program
+self=pst
+
+# Don't accept terminal as stdin
+if [ -t 0 ] ; then
+ printf >&2 '%s: stdin is a term\n' "$self"
+ exit 2
+fi
+
+<%
+include(`include/mktd.m4')
+%>
+
+# Run the interactive command on the temporary file forcing /dev/tty as
+# input/output
+tf=$td/data
+cat - > "$tf" || exit
+"${@:-"${PAGER:-more}"}" "$tf" </dev/tty >/dev/tty
+cat -- "$tf" || exit