#!/bin/sh -u # # Exec command only if input is not empty. # - Cameron Simpson 23jun1998 # : ${TMPDIR:=/tmp} cmd=$0 usage="Usage: $cmd command [args...]" [ $# = 0 ] && { echo "$usage" >&2; exit 2; } tmp=$TMPDIR/execif.$$ trap 'rm -f "$tmp"' 0 trap 'rm -f "$tmp"; exit 1' 1 2 13 15 stripwhite >"$tmp" || exit 1 [ -s "$tmp" ] || exit 0 "$@" <"$tmp"