[tz] [PATCH 4/4] tzselect: Work around an old BusyBox awk bug.

Patrick 'P. J.' McDermott pj at pehjota.net
Sat Oct 5 16:36:01 UTC 2013


Before version 1.21.0, BusyBox awk didn't unescape the argument to the -F
option.  As a result, tzselect couldn't parse tables with such versions of
BusyBox awk.  See <https://bugs.busybox.net/show_bug.cgi?id=5126> and
<http://git.busybox.net/busybox/commit?id=ea664dd>.
* tzselect.sh: Replace "\t" in awk -F arguments with the tab character.
---
 tzselect.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tzselect.sh b/tzselect.sh
index 72e7504..829a808 100644
--- a/tzselect.sh
+++ b/tzselect.sh
@@ -219,7 +219,8 @@ while
 	echo >&2 'Please select a continent, ocean, "coord", or "TZ".'
 
         quoted_continents=$(
-	  $AWK -F'\t' '
+	  $AWK '
+	    BEGIN { FS = "\t" }
 	    /^[^#]/ {
               entry = substr($3, 1, index($3, "/") - 1)
               if (entry == "America")
@@ -312,10 +313,11 @@ while
 		    ;;
 		*)
 		# Get list of names of countries in the continent or ocean.
-		countries=$($AWK -F'\t' \
+		countries=$($AWK \
 			-v continent="$continent" \
 			-v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \
 		'
+			BEGIN { FS = "\t" }
 			/^#/ { next }
 			$3 ~ ("^" continent "/") {
 				if (!cc_seen[$1]++) cc_list[++ccs] = $1
@@ -350,11 +352,12 @@ while
 
 
 		# Get list of names of time zone rule regions in the country.
-		regions=$($AWK -F'\t' \
+		regions=$($AWK \
 			-v country="$country" \
 			-v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \
 		'
 			BEGIN {
+				FS = "\t"
 				cc = country
 				while (getline <TZ_COUNTRY_TABLE) {
 					if ($0 !~ /^#/  &&  country == $2) {
@@ -381,12 +384,13 @@ while
 		esac
 
 		# Determine TZ from country and region.
-		TZ=$($AWK -F'\t' \
+		TZ=$($AWK \
 			-v country="$country" \
 			-v region="$region" \
 			-v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \
 		'
 			BEGIN {
+				FS = "\t"
 				cc = country
 				while (getline <TZ_COUNTRY_TABLE) {
 					if ($0 !~ /^#/  &&  country == $2) {
-- 
Patrick "P. J." McDermott
  http://www.pehjota.net/
Lead Developer, ProteanOS
  http://www.proteanos.com/


More information about the tz mailing list