All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald van Dijk <harald@gigawatt.nl>
To: "Herbert Xu" <herbert@gondor.apana.org.au>,
	наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: dash@vger.kernel.org
Subject: Re: [PATCH v2 2/3] parser: synerror: explicitly consume the entire invalid line
Date: Tue, 3 Jan 2023 11:47:05 +0000	[thread overview]
Message-ID: <bb422d70-0ba5-e29b-3ec8-8fc1c4630233@gigawatt.nl> (raw)
In-Reply-To: <Y7OKk/jM53zRE4xg@gondor.apana.org.au>

On 03/01/2023 01:53, Herbert Xu wrote:
> наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
>>
>> synerror(const char *msg)
>> {
>>         errlinno = plinno;
>> +
>> +       /* If we see a syntax error in a command, read the rest of the
>> +        * line now before reporting the error. This ensures we get error
>> +        * reporting that does not depend on buffering details. */
>> +       skipline();
> 
> This is broken.  What if we already read a newline just before
> the syntax error (e.g., synexpect(TDO))?

In order for this to be a problem, we need something where the newline 
itself triggers a syntax error. For synexpect(TDO), is that possible? In 
all cases where synexpect(TDO) is called, a newline is permitted, and it 
is the token after the newline that the error will be reported on, no? 
In that situation, reading the rest of the line is correct.

I'm not going to rule out that there is a potential for problems, but if 
there is, it's not the situation you say.

> This needs to be dealt with in the input layer.

Handling it in the input layer after the error has already been reported 
means we get inconsistent error handling when running with dash -isv. 
The error may, depending on whether the rest of the line was in the 
buffer already, be reported either in the middle of the input line, or 
on the next line.

Just try changing sh -i to sh -iv in the reproducer and seeing what what 
happens with your patch.

Cheers,
Harald van Dijk

  parent reply	other threads:[~2023-01-03 11:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 22:17 [PATCH] input: preadfd: read standard input byte-wise наб
2022-12-13 22:37 ` Harald van Dijk
2022-12-14  1:05   ` наб
2022-12-14  1:06     ` [PATCH v2 1/3] parser: fixredir: invalid redirections are run-time, not syntax наб
2023-01-05  9:43       ` Herbert Xu
2022-12-14  1:06     ` [PATCH v2 2/3] parser: synerror: explicitly consume the entire invalid line наб
2023-01-03  1:53       ` Herbert Xu
2023-01-03  5:32         ` [PATCH] input: Eat rest of line upon reset Herbert Xu
2023-01-03 11:47         ` Harald van Dijk [this message]
2023-01-04  9:51           ` [PATCH v2 2/3] parser: synerror: explicitly consume the entire invalid line Herbert Xu
2023-01-04 11:25             ` Harald van Dijk
2023-01-04 14:10               ` Herbert Xu
2023-01-04 14:30                 ` Harald van Dijk
2023-01-04 14:41                   ` Herbert Xu
2023-01-04 14:59                     ` Harald van Dijk
2023-01-05  7:12                       ` [PATCH] input: Check for int_pending while clearing input Herbert Xu
2022-12-14  1:06     ` [PATCH v2 3/3] input: preadfd: read standard input byte-wise наб
2023-01-03  6:15       ` [v3 PATCH] input: Read " Herbert Xu
2023-01-03 11:54         ` Harald van Dijk
2023-01-04  8:59           ` Herbert Xu
2023-01-04 11:18             ` Harald van Dijk
2023-01-05  7:26               ` [PATCH] input: Only skip blank lines on PS1 Herbert Xu
2023-01-05  8:33                 ` Harald van Dijk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb422d70-0ba5-e29b-3ec8-8fc1c4630233@gigawatt.nl \
    --to=harald@gigawatt.nl \
    --cc=dash@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.