bug-gawk
[Top][All Lists]
Advanced

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

Re: gawk 4.0.2 issue - "fatal: not enough arguments to satisfy format st


From: david kerns
Subject: Re: gawk 4.0.2 issue - "fatal: not enough arguments to satisfy format string"
Date: Sun, 8 Mar 2020 16:02:29 -0700

The real problem is your 2nd printf has no format string (the
first argument to printf), and then the argument you pass contains a %
try this:

$ cat b|awk
'{for(i>0;i<=NR;i++)a[i]=$0}END{for(j=0;3*j+1<i;j++){printf"|";for(k=1;k<=3;k++)printf
*"%s"*, a[3*j+k]"|";printf"\n"}}'
|1|2% A|3|
|4|5|6|



On Sun, Mar 8, 2020 at 3:50 PM Zhu, John (Nokia - CN/Shanghai) <
address@hidden> wrote:

> Hello Developers,
>
> My name is John Zhu and I am a software engineer in Nokia China.
>
> I found an issue with gawk 4.0.2 on my RHEL 7.6 VM, please help to check
> if it's a potential bug.
>
> I have two text files a and b with only one byte different.
> The last character of the second line in file a is letter "o" in lower
> case while in the same location in file b is letter "A" in upper case.
> [root@betactvdh:/tmp]# cat a
> 1
> 2% o
> 3
> 4
> 5
> 6
> [root@betactvdh:/tmp]# cat b
> 1
> 2% A
> 3
> 4
> 5
> 6
> [root@betactvdh:/tmp]# diff a b
> 2c2
> < 2% o
> ---
> > 2% A
> [root@betactvdh:/tmp]# hexdump -C a
> 00000000  31 0a 32 25 20 6f 0a 33  0a 34 0a 35 0a 36 0a     |1.2%
> o.3.4.5.6.|
> 0000000f
> [root@betactvdh:/tmp]# hexdump -C b
> 00000000  31 0a 32 25 20 41 0a 33  0a 34 0a 35 0a 36 0a     |1.2%
> A.3.4.5.6.|
> 0000000f
> [root@betactvdh:/tmp]#
> [A close up of a screen  Description automatically generated]
> Awk version is GNU Awk 4.0.2.
> [root@betactvdh:/tmp]# awk --version
> GNU Awk 4.0.2
> Copyright (C) 1989, 1991-2012 Free Software Foundation.
>
> This program is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 3 of the License, or
> (at your option) any later version.
>
> This program is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> GNU General Public License for more details.
>
> You should have received a copy of the GNU General Public License
> along with this program. If not, see http://www.gnu.org/licenses/.
> [root@betactvdh:/tmp]#
>
> I run the same command to folder the six line text into two lines.
> It works with file b:
> [root@betactvdh:/tmp]# cat b|awk
> '{for(i>0;i<=NR;i++)a[i]=$0}END{for(j=0;3*j+1<i;j++){printf"|";for(k=1;k<=3;k++)printf
> a[3*j+k]"|";printf"\n"}}'
> |1|2% A|3|
> |4|5|6|
>
> But it doesn't work with file a:
> [root@betactvdh:/tmp]# cat a|awk
> '{for(i>0;i<=NR;i++)a[i]=$0}END{for(j=0;3*j+1<i;j++){printf"|";for(k=1;k<=3;k++)printf
> a[3*j+k]"|";printf"\n"}}'
> |1|awk: cmd. line:1: (FILENAME=- FNR=6) fatal: not enough arguments to
> satisfy format string
>         `2% o|'
>            ^ ran out for this one
>
> [A screenshot of a cell phone  Description automatically generated]
> I also tested on other awk releases and found same issue on GNU Awk 3.1.7
> as well.
> [cid:image003.png@01D5F5D6.0066C800]
>
> Please advise why it is happening.
>
> Thanks & Regards,
> John
>
>


reply via email to

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