[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in AWK
From: |
Neil R. Ormos |
Subject: |
Re: bug in AWK |
Date: |
Fri, 13 Aug 2021 18:41:05 -0500 (CDT) |
Evgeny Smirnov wrote:
> It seems I've found a bug in awk.
============================================================
> script.awk:
> BEGIN{
> OFS=","
> }
> {
> "date -d \""$0"\" +%H" | getline d
> print $0, d
> }
============================================================
> data.txt:
> 2016-09-04 20:14:29
> 2016-09-04 19:14:29
> 2016-09-04 20:14:29
============================================================
You forgot to call close() after the pipe to getline.
E.g.,
close("date -d \""$0"\" +%c");
See the manual:
| If the same file name or the same shell command
| is used with getline more than once during the
| execution of an awk program (see section
| Explicit Input with getline), the file is opened
| (or the command is executed) the first time
| only.
<https://www.gnu.org/software/gawk/manual/gawk.html#Close-Files-And-Pipes>
- bug in AWK, Evgeny Smirnov, 2021/08/13
- Re: bug in AWK,
Neil R. Ormos <=