#!/bin/sh set -e # see parent-process Y- y='' g='' x='' # notes #"$@" <"$f" #no quotes? # end Die() { exit $1 } usage() { printf >&2 '%s\n' 'usage: Y FILE [CMD...]'\ 'stream-out [ nil or CMD ] &2 '%s\n' 'Y: shell satisfies [ "$(eval echo "$(quote "'\''| "\")")" != "'\''| "\" ]'\ 'to procede with use, look inside quote(){...}' Die 1 fi case $Y in [0-9]*) y=$(echo "$Y" |grep -o "^[0-9]*") Y=$(echo "$Y" |sed "s/^[0-9]*//") ;; esac case $Y in ''|u) if [ -z "${y:+s}" ];then [ $# -lt 1 ]&& usage f="$1" shift 1 fi ;; *[^nud]*) printf >&2 '%s\n' 'Y: malformed $Y' Die 1 ;; *) y=0 ;; esac case "$Y" in *u*) x="$@" ;; *) x=$(quote "$@") [ "$x" = "''" ]&& x="" ;; esac case $Y in *d*) printf '%s\n' "$x" ;; *n*) eval "$x" ;; *) if [ -z "${y:+s}" ];then <"$f" eval "$x" else <&$y eval "$x" fi ;; esac