aboutsummaryrefslogtreecommitdiff
path: root/bin/oii.mi5
blob: 914d45f97ceba055bd3181f30346cd47b13f03e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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')
%>

# Read up to one byte and save it into temp file; discard stderr (stats)
tf=$td/input
dd bs=1 count=1 of="$tf" 2>/dev/null

# If there's now a byte in the file, spit it and the rest of the input into the
# requested command
[ -s "$tf" ] && cat -- "$tf" - | "$@"