On 4/4/17 5:08 PM, nesro wrote:

> 
> To have both commands similar, let's assume the while as this:
> 
> while (( 1 > 2 )); do :; done
> 
> Thanks for explaining me why it happen, but now I don't know why for cycle
> works and while does not.
When extdebug is enabled, the command is skipped if the DEBUG trap returns
non-zero.  This doesn't change $? (traps never do) and it doesn't cause the
command that would have been run to return a non-zero exit status.  If it
did, the combination of DEBUG and `set -e' would exit the shell, for
example, and I'm sure it would not behave as the bash debugger would
expect.  For that matter, why should a command that's not run fail?

Since that command returns successfully, when it's used as the `while'
command test, it causes the while command to execute forever.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to