Tip Of The Week

This fragment of shell doesn't do what you'd expect at a quick glance:

if [ $? -ne 0 ]; then
    exit $?
fi

The act of checking $? causes $? to be set to the result of the test, so this executes exit 0 if $? is non-zero.

NP: Cosmos, Murcof

11:20 Friday, 17 Aug 2007 [#] [computers] (5 comments)