[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: strange bash behavior



On Mon, 02 Sep 2013 12:26:17 -0400 (EDT), Stephen Powell wrote:
> 
> Interesting.  If "break" appears out of context, you should get
> an error message something like:
> 
>    bash: break: only meaningful in a 'for', 'while', or 'until' loop
> 
> You didn't get an error message, so part of bash thinks it is in context.
> Yet it did not exit the loop.  It seems to me that you should get one
> behavior or the other.  Either you should get an error message or it
> should exit the loop.

I just tried this in both ash and dash.  Neither one of them produce an
error message when break is issued out of context.  It simply executes
as a no-op.  (break is a shell built-in command, of course, not an
external command.)  So despite the fact that break is not producing an error
message when one might expect it to, it is apparently exhibiting
"expected behavior" in the sense that output is identical to what would
occur with ash and dash.  (Issue "busybox ash" to get ash.  exit to exit,
of course.)

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


Reply to: