bug-bash
[Top][All Lists]
Advanced

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

Re: Bug in syntax checking causes unintended running of a function


From: David Maas
Subject: Re: Bug in syntax checking causes unintended running of a function
Date: Wed, 20 Apr 2016 11:39:02 -0700

Fair enough.

On Wed, Apr 20, 2016 at 8:44 AM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
On Wed, Apr 20, 2016 at 08:30:48AM -0700, David Maas wrote:
> So if you really want my opinion, the shell should be aware that it's in a
> function.

Agreed, unless it's really hard to do.

> You could possibly implement this by keeping track of the parent
> pid.

Nonsense.  Function calls do not create a child process.  But the
issue here has nothing to do with function calls in the first place.
It's about parsing the script.

You wanted this:

a() {
  an egregious syntax error
  b
}

c

To be parsed like this:

c

But bash parsed it like this:

  b
}
c

> Another solution would be to not check the syntax of the function
> until the function is actually run.

Then how do you know where the function definition ends?  You have to
parse the function definition at the time you are reading that piece
of the script.

Could the parser's error handling be improved?  Certainly.  But I won't
be the one to write it, and I don't feel it's fair to demand that Chet
write it either.  At some point, the script programmer has to take
responsibility for the script's errors.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]