[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] errexit and attempting to change readonly functions
From: |
Andy Chu |
Subject: |
Re: [Help-bash] errexit and attempting to change readonly functions |
Date: |
Fri, 27 Sep 2019 13:56:36 -0700 |
Yeah I would consider this a bug, but pedantically speaking bash's docs are
correct, since a function definition is not part of the compound_command
production according to POSIX.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02
FWIW I don't really ilke the style of referring to the grammar in the
docs. Another example is the subtlety of 'time [-p] pipeline'. That is,
it's not a builtin but a keyword that prefixes a pipeline.
command : simple_command
| compound_command
| compound_command redirect_list
| function_definition
;
compound_command : brace_group
| subshell
| for_clause
| case_clause
| if_clause
| while_clause
| until_clause
On Fri, Sep 27, 2019 at 1:44 PM Greg Wooledge <address@hidden> wrote:
>
> On Fri, Sep 27, 2019 at 09:28:24PM +0100, Stephane Chazelas wrote:
> > It seems as if bash tried to avoid triggering errexit when it
> > can get away (wrt posix conformance) with not to.
>
> The man page says,
>
> Exit immediately if a pipeline (which may consist of a
> single simple command), a list, or a compound command
> (see SHELL GRAMMAR above), exits with a non-zero status.
>
> I don't see function declarations included under "compound command"
> in that section. So the question, for me, is whether a function
> declaration counts as a pipeline, a list, or a compound command (or
> none of the above).
>
> I'm about 90% sure it doesn't count as a compound command, since
> the grammar for a function declaration includes "compound-command"
> right after the "()" part. Not sure about pipeline/list.
>