bug-gawk
[Top][All Lists]
Advanced

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

Re: gawk skipping ./file name containing =


From: Ed Morton
Subject: Re: gawk skipping ./file name containing =
Date: Sun, 3 Oct 2021 12:55:11 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0



On 10/3/2021 12:41 PM, Davide Brini wrote:
On Sun, 3 Oct 2021 19:26:29 +0200, Davide Brini <dave_br@gmx.com> wrote:

Doesn't seem to be related to the filenames though, I see the same output
with a file named "foo":

$ cat foo
here

$ cat file1
1
2
3

$ printf './%s\n' foo file1 | awk 'NR==FNR{ARGV[ARGC++]=$0; next} {print
FILENAME, $0}'
./file1 1
./file1 2
./file1 3

This seems to work though, not sure it's as expected or we're hitting a dark
corner here:

$ printf './%s\n' foo file1 | awk '
BEGIN{ARGV[ARGC++]="-"}
NR==FNR{ARGV[ARGC++]=$0; next}
{print FILENAME, $0}'
./foo here
./file1 1
./file1 2
./file1 3

--
D.

Ah, you're right on both counts. It's not the `=` in the file name that's the issue, it's that I should have done:

   printf ... | awk 'script' -

(with `-` on the end) so that I started populating ARGV[] at ARGV[2] instead of ARGV[1] since ARGV[1] was already consumed when the `NR==FNR` block was being interpreted.

Thanks,

    Ed.


reply via email to

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