exit code "before"

Hej,

is there any way to receive the exit code of the command "before" the last command?

When executing something like:

command &> /dev/null &
echo $?

I get 0 ( I think for successfully redirecting to /dev/null )

But i'm interested in getting the exit code of "command".

Thanks for your help ... Greetings

Redirection of output should not be changing the return codes of the programs. The redirection is not carried out by a seperate progam, it is done by the shell. So the $? will contain the return value from 'command'.

you are right.
redirecting doesn't change the exit code but switching the command to background processing does ... so i think the problem still exists but the reason changed

Greetings

Dear karlssohn,

You cab write down a wrapper for it. Something like this......

##file test.sh

echo hello world
echo "the exit status of the cmd was $?"

then you can run test.sh& and get the result!!