Permalink
Browse files

tzselect: work around an old BusyBox awk bug

Patch by Patrick 'P. J.' McDermott in
<http://mm.icann.org/pipermail/tz/2013-October/020444.html>.
* tzselect.ksh: Replace awk -F options with FS assignments.
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>.
* NEWS: Document this.
  • Loading branch information...
eggert committed Oct 6, 2013
1 parent be06aa4 commit 868ed00c10f1df7fc89d02915ae4ed399d2cd224
Showing with 11 additions and 6 deletions.
  1. +3 −2 NEWS
  2. +8 −4 tzselect.ksh
View
5 NEWS
@@ -11,8 +11,9 @@ Unreleased, experimental changes
Changes affecting API
The 'tzselect' command no longer requires the 'select' command,
and should now work with /bin/sh on more platforms. (Thanks to
Patrick 'P. J.' McDermott for reporting the problem.)
and should now work with /bin/sh on more platforms. It also works
around a bug in BusyBox awk before version 1.21.0. (Thanks to
Patrick 'P. J.' McDermott.)
Changes affecting the build procedure
View
@@ -259,7 +259,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")
@@ -347,10 +348,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
@@ -383,11 +385,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) {
@@ -412,12 +415,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) {

0 comments on commit 868ed00

Please sign in to comment.