[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] What is wrong with getline from both stdin and a file fro
From: |
Peng Yu |
Subject: |
Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV? |
Date: |
Wed, 28 Nov 2018 16:27:40 -0600 |
> Because the first getline reads from /dev/fd/63, and then when
> you call "getline < ARGV[1]", it accesses /dev/fd/63 again. When the
> program exits, it tries to close all open files. First, it closes
> the file on the command line /dev/fd/63, and then it closes
> fd 63 again because you explicitly opened it using the "getline < ARGV[1]"
> syntax. Note that the pipe on stdin is a distraction and has no
> impact on the results.
strace is from Linux. I currently use Mac so I can not try it. But why
the third way works. It also uses the same file handle.
$ printf '%s\n' {1..3} | awk -v f=<(printf '%s\n' {a..c}) -e 'BEGIN {
print f; getline; print; getline < f; print }'
/dev/fd/63
1
a
--
Regards,
Peng
- [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Peng Yu, 2018/11/28
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Andrew J. Schorr, 2018/11/28
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?,
Peng Yu <=
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Andrew J. Schorr, 2018/11/28
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Peng Yu, 2018/11/28
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Andrew J. Schorr, 2018/11/28
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Peng Yu, 2018/11/28
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, Andrew J. Schorr, 2018/11/29
- Re: [bug-gawk] What is wrong with getline from both stdin and a file from ARGV?, arnold, 2018/11/29