is there an alternative to \"tee\" which captures STDOUT/STDERR of the command being executed and exits with the same exit status as the processed command. Something as followin
#!/bin/sh logfile="$1" shift exec 2>&1 exec "$@" | tee "$logfile"
Hopefully this works for you.