[tz] [PROPOSED PATCH] tzselect: Fix for gawk treating '\.' as plain '.'

Paul Eggert eggert at cs.ucla.edu
Sun Nov 23 01:33:47 UTC 2014


From: Stefan Kuhn <Wuodan0 at gmail.com>

When using gawk and Posix TZ in tzselect, this warning is shown:
	awk: cmd. line:1: warning: escape sequence `\.' treated as plain `.'
gawk treats '\.' as '.'
mawk treats '\.' as '\.'
both treat '\\.' as '\\.'
The 2nd and 3rd are corrrect for 'Mm.w.d'.

Test:
gawk 'BEGIN{ date = "\."; print date }'
gawk 'BEGIN{ date = "\\."; print date }'
versus:
mawk 'BEGIN{ date = "\."; print date }'
mawk 'BEGIN{ date = "\\."; print date }'
* tzselect.ksh (date): Fix bug that broke POSIX TZ checking with gawk.
* NEWS: Document this.
---
 NEWS         | 3 +++
 tzselect.ksh | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 1e781d2..45e4f84 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ Unreleased, experimental changes
     that tzset always has, by replacing invalid bytes with '_' and by
     shortening too-long abbreviations.
 
+    tzselect no longer mishandles POSIX TZ settings when GNU awk is used.
+    (Thanks to Stefan Kuhn.)
+
   Changes affecting build procedure
 
     'make check' now checks for links to links in the data.
diff --git a/tzselect.ksh b/tzselect.ksh
index 029abcd..d5dae17 100644
--- a/tzselect.ksh
+++ b/tzselect.ksh
@@ -328,7 +328,7 @@ while
 				tzname = "[^-+,0-9][^-+,0-9][^-+,0-9]+"
 				time = "[0-2]?[0-9](:[0-5][0-9](:[0-5][0-9])?)?"
 				offset = "[-+]?" time
-				date = "(J?[0-9]+|M[0-9]+\.[0-9]+\.[0-9]+)"
+				date = "(J?[0-9]+|M[0-9]+\\.[0-9]+\\.[0-9]+)"
 				datetime = "," date "(/" time ")?"
 				tzpattern = "^(:.*|" tzname offset "(" tzname \
 				  "(" offset ")?(" datetime datetime ")?)?)$"
-- 
2.1.0



More information about the tz mailing list