[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk: unexpected behavior, but not a bug
From: |
Thomas Schwinge |
Subject: |
gawk: unexpected behavior, but not a bug |
Date: |
Thu, 19 Jul 2007 18:38:11 +0200 |
User-agent: |
Mutt/1.5.11 |
Hello!
They told me it's not a gawk (GNU Awk 3.1.5) bug, but I thought I'd
nevertheless report it here.
Given the attached `ThomasSchwinge.txt' it took me roughly one hour and
finally the help of three people in the freenode #awk irc channel to
figure out what was going on here:
#v+
$ awk < data/Main/ThomasSchwinge.txt 'BEGIN { FS = ": "; name = "unknown";
email = "address@hidden" } $1 ~ /\* Name$/ { name = $2 } $1 ~ /\* Email$/ {
email = $2 } END { print name " <" email ">" }'
><address@hidden
#v-
I had expected to get ``Thomas Schwinge <address@hidden>'' as output.
In the end `igli' and `redondos' had an idea:
#v+
$ awk < data/Main/ThomasSchwinge.txt 'BEGIN { FS = ": "; name = "unknown";
email = "address@hidden" } { sub("\r$", "") } $1 ~ /\* Name$/ { name = $2 } $1
~ /\* Email$/ { email = $2 } END { print name " <" email ">" }'
Thomas Schwinge <address@hidden>
#v-
Who would have thought about that... Not me, for sure.
Regards,
Thomas
ThomasSchwinge.txt
Description: Text document
signature.asc
Description: Digital signature
- gawk: unexpected behavior, but not a bug,
Thomas Schwinge <=