bug-gawk
[Top][All Lists]
Advanced

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

Re: awk -f error message sometimes prints wrong line


From: arnold
Subject: Re: awk -f error message sometimes prints wrong line
Date: Thu, 10 Feb 2022 01:39:53 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Thanks for the report.

This part of the code is a bit messy.  I am not sure that I can
improve the situation, but I will try to take a look at it sometime soon.

Thanks,

Arnold

Shlomo <shlomo@fastmail.com> wrote:

> Using Gawk 5.1.1:
>
> $ cat a.awk
>
> BEGIN {}
> {
> $ awk -f a.awk
> awk: a.awk:3: B
> awk: a.awk:3: ^ unexpected newline or end of string
>
> Note the error message mentions line 3, but the "B" seems to come from line 2.
> When writing the program inline, the error message is good:
>
> $ awk '
> > BEGIN {}
> > {'
> awk: cmd. line:3: {
> awk: cmd. line:3:  ^ unexpected newline or end of string
>
> If I change the first line to be non-empty, I get a different error message:
>
> $ cat a.awk
> {}
> BEGIN {}
> {
> $ awk -f a.awk
> awk: a.awk:3: (END OF FILE)
> awk: a.awk:3: ^ source files / command-line arguments must contain complete 
> functions or rules
>
> But this error message too doesn't print the contents of line 3. Writing the 
> program inline gives a good error message:
>
> $ awk '{}
> > BEGIN {}
> > {'
> awk: cmd. line:3: {
> awk: cmd. line:3:  ^ unexpected newline or end of string



reply via email to

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