bug-gawk
[Top][All Lists]
Advanced

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

awk -f error message sometimes prints wrong line


From: Shlomo
Subject: awk -f error message sometimes prints wrong line
Date: Wed, 09 Feb 2022 09:34:59 +0200
User-agent: Cyrus-JMAP/3.5.0-alpha0-4748-g31a5b5f50e-fm-cal2020-20220204.001-g31a5b5f5

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]