I have the following bash script:
STDIN='&0'
if some-condition; then
STDIN=some-filename
fi
run-command <${STDIN}
But that errors with &0: No such file or directory.
Similarly for STDOUT.
I’ve tried using eval but haven’t gotten that to work, either.
What needs to be done to get this to work?
>Solution :
STDIN=’/dev/stdin’ # Default to stdin
if some-condition; then
STDIN=’some-filename’
fi
Similarly, for STDOUT
STDOUT=’/dev/stdout’ # Default to stdout
if some-other-condition; then
STDOUT=’some-other-filename’
fi
run-command <"$STDIN" >"$STDOUT"