Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Unexpected behavior with “set -o errexit” on AIX

Unexpected behavior with “set -o errexit” on AIX

Unexpected behavior with “set -o errexit” on AIX

This script shell works fine on GNU/Linux but not on AIX 5.3 and later :

CODE -->


echo $SHELL

set -o nounset -o errexit

[ 1 -eq 1 ] && {
  echo "zzz"
} && echo "aaa" && [ 1 -eq 0 ] && echo "bbb"
echo "ccc" 

On GNU/Linux, I've got the expected output :



On AIX, I've got this one :



Without "set -o nounset -o errexit" it works fine... I don't understant why. Could you explain me what is wrong in my script shell.

man ksh :


Executes the ERR trap, if set, and exits if a command has a nonzero exit status, unless in the following conditions:
* The simple command is contained in a "&&" or "||" list.
* The simple command immediately follows "if", "while" or "until".
* The simple command is contained in a pipeline following "!".
This mode is disabled when profiles are read.

In my example, the second test "[ 1 -eq 0 ]" is part of an AND, so I should see the output "ccc". This test returns 1, it traps the output "bbb", but should'nt exit the script.



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close