Hi Martin, thanks for reply. > > # run an empty for cycle. we can see from the output that bash ran :, then > > # false and stopped to it. which is the right behavior > > for (( :; false; )); do :; done > > This is a syntax error. 'for' takes arithmetic expressions, not shell > commands.
Sorry, my bad. I just wanted to make the command as simple as possible to demonstrate the order of execution and I didn't notice that I got into an invalid command. It's the same with this, valid, command: for (( ; 1 > 2; )); do :; done > > # now run this while cycle. it just cycle the debug trap forever > > while false; do :; done > The 'false' command is never executed so never has the chance to return > an exit status of "false" (1). 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. The for cycle run the condition (after setting: t() { return 1; }; trap t DEBUG; shopt -s extdebug) bash-4.3$ for (( ; 1 > 2; )); do :; done + (( 1 )) ++ t ++ return 1 + (( 1 > 2 )) ++ t ++ return 1 but the while cycle does not: bash-4.3$ while (( 1 > 2 )); do :; done ++ t ++ return 1 ++ t ++ return 1 .. loop forever .. Is there any workaround to achieve the functionality I want? That is: Prevent execution of everything by default. I will decide what to run by using eval from the debug trap. Thanks, Tomas