Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: exit status



Aside:  Here's an actual bug:

   zsh -fc 'trap "echo \$?" EXIT; echo ${example?oops}'

The EXIT trap is not called when the shell exits on the error caused
by the ${var?message} construct.  (Bash prints "127" in this case;
also, the exit status of zsh on that construct is 1 rather than 127,
but I don't know why bash chose 127.)

On Nov 10,  4:09pm, Peter Stephenson wrote:
}
} I can see arguments for both sides; it turns whether you consider the
} "exit" command itself to have been executed before the exit traps run,
} which is a bit Zen-like.

Think of it as a C program.  If

    int question_mark = 0;
    atexit() { printf("%d\n", question_mark); }
    main() { question_mark = exit(3); }

is a valid program and, when run, prints "3", then I'm on your side.
Otherwise I'm with Cragun.



Messages sorted by: Reverse Date, Date, Thread, Author