aboutsummaryrefslogtreecommitdiff
path: root/bin/oii.mi5
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-06-29 17:46:34 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-06-29 17:46:34 +1200
commita9e25e51ca3c96d3b5bfc86ab5a45c5bee818152 (patch)
tree83af4372bd66751ed959db5af3ebfdb63fdcc431 /bin/oii.mi5
parenta5483bdce6c553c6908c447cd6b6d7a89d61e22c (diff)
downloaddotfiles-a9e25e51ca3c96d3b5bfc86ab5a45c5bee818152.tar.gz
dotfiles-a9e25e51ca3c96d3b5bfc86ab5a45c5bee818152.zip
Add oii(1df)
Diffstat (limited to 'bin/oii.mi5')
-rw-r--r--bin/oii.mi519
1 files changed, 19 insertions, 0 deletions
diff --git a/bin/oii.mi5 b/bin/oii.mi5
new file mode 100644
index 00000000..51f37fb4
--- /dev/null
+++ b/bin/oii.mi5
@@ -0,0 +1,19 @@
+# Only run a command on input if there was at least one byte
+self=oii
+
+# Need at least a command name
+if [ "$#" -eq 0 ] ; then
+ printf >&2 '%s: Need a command\n' "$self"
+ exit 2
+fi
+
+<%
+include(`include/mktd.m4')
+%>
+
+# There is probably a way better way to do this than writing the whole file to
+# disk and then reading it off again, but until I think of something better,
+# this works and is byte-safe.
+cat - > "$td"/in
+[ -s "$td"/in ] || exit
+"$@" < "$td"/in