Here's an easy way to turn a two argument bash script into a filter. It
needs to be invoked like io_assignment IN $1 $2. The DEFAULT
option is for setting what the default behavior is with only one
argument. Sticking this into a library is probably recommended (hrm,
this may be harder than it sounds as bash doesn't appear to respect
variables set in a function in an included file.)
io_assignment () {
DEFAULT="$1"
shift
case "$#" in
0) IN_FILE="/dev/stdin"
OUT_FILE="/dev/stdout"
;;
1) case DEFAULT in
IN) IN_FILE="$1"
OUT_FILE="/dev/stdout"
;;
OUT) IN_FILE="/dev/stdin"
OUT_FILE="$1"
;;
esac
;;
2) IN_FILE="$1"
OUT_FILE="$2"
;;
esac
}
Also shell seems to be capable of allowing you to write code that needs a million error checks which I have not done.
