Search code examples
bashunixscriptingshexitstatus

Bourne Shell: Graceful way to get exit status


Is there a more graceful way to do this (bourne shell)?

IsThereAnyApplesLeft
applesLeft=$?

Normally in c or java I would do:

applesLeft=IsThereAnyApplesLeft

Solution

  • Exit status is normally used implicit like this:

    if IsThereAnyApplesLeft;then
       echo "Apples left"
    fi