Mitar wrote: > Hi! > > I have found a discrepancy between documentation (man page) and > behavior of Bash under -e switch. In documentation it is written: > > The shell does not exit if the command that fails is part of the > command list immediately following a while or until keyword, part of > the test in an if statement, part of a && or || list, or if the > command's return value is being inverted via !.
The language in the man page is pretty much straight out of Posix, but the bash-3.2 behavior does differ. Historical shell behavior and implementor consensus are that the failure of the rightmost command in an AND or OR list should cause the shell to exit. The language in the bash-4.0 man page documents the behavior: Exit immediately if a pipeline (which may consist of a single simple command), a subshell command enclosed in parentheses, or one of the commands executed as part of a command list enclosed by braces (see SHELL GRAMMAR above) exits with a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/