Skip to content

Commit

Permalink
tzselect: work around an old BusyBox awk bug
Browse files Browse the repository at this point in the history
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 868ed00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 8 additions & 4 deletions tzselect.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 868ed00

Please sign in to comment.