Para evitar o uso de eval
:
opt_file=""
# Command line parsing bit here, setting opt_file to a
# file name given by the user, or leaving it empty.
if [[ -z "$opt_file" ]]; then
outfile="/dev/stdout"
else
outfile="$opt_file"
fi
exec echo hi >>"$outfile"