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

Re: strange bash behavior



On Tue, 2013-09-03 at 20:01 -0400, William Hopkins wrote: 
> On 09/03/13 at 03:45pm, Joe Pfeiffer wrote:
> > Stephen Powell <zlinuxman@wowway.com> writes:
> > >
> > > 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.
> > 
> > Good point -- it is odd that it isn't giving the error message.
> 
> The loop context is inherited by the subshell, so break thinks it is fine. It
> is only that it is totally meaningless to break there, since that signal cannot
> be captured by parent shell environment. 
> 
> This seems to be expected behavior..
> 

I would say so. The list creates a second shell that is not reporting
the error message back to the parent shell because the error was
supposed to be of minor importance and not critical to the parent. The
message is most likely sent to the subshell before it's killed remaining
hidden from stdout. But you should check this out, I'm just saying it
makes sense.



Reply to: