[PROPOSED 1/2] Fix stray ‘\’ in tzselect
* tzselect.ksh: Remove stray backslash that messed up the wording of a diagnostic. This glitch was introduced in commit 13980693084c36e0275828d8d46d9d9e8975be0d dated Wed Jun 27 11:24:09 2018 -0700. --- tzselect.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tzselect.ksh b/tzselect.ksh index 87baaa5..cbfc677 100644 --- a/tzselect.ksh +++ b/tzselect.ksh @@ -401,7 +401,7 @@ while BEGIN { FS = "\t" } { print $NF } '` - echo >&2 'Please select one of the following timezones,' \ + echo >&2 'Please select one of the following timezones,' echo >&2 'listed roughly in increasing order' \ "of distance from $coord". doselect $regions -- 2.39.0
* tzselect.ksh: Refactor to avoid the need for a couple of pipes and subprocesses. --- tzselect.ksh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tzselect.ksh b/tzselect.ksh index cbfc677..dc3ad11 100644 --- a/tzselect.ksh +++ b/tzselect.ksh @@ -397,18 +397,33 @@ while sort -n | sed "${location_limit}q" ` - regions=`say "$distance_table" | $AWK ' - BEGIN { FS = "\t" } - { print $NF } + regions=`$AWK \ + -v distance_table="$distance_table" ' + BEGIN { + nlines = split(distance_table, line, /\n/) + for (nr = 1; nr <= nlines; nr++) { + nf = split(line[nr], f, /\t/) + print f[nf] + } + } '` echo >&2 'Please select one of the following timezones,' echo >&2 'listed roughly in increasing order' \ "of distance from $coord". doselect $regions region=$select_result - TZ=`say "$distance_table" | $AWK -v region="$region" ' - BEGIN { FS="\t" } - $NF == region { print $4 } + TZ=`$AWK \ + -v distance_table="$distance_table" \ + -v region="$region" ' + BEGIN { + nlines = split(distance_table, line, /\n/) + for (nr = 1; nr <= nlines; nr++) { + nf = split(line[nr], f, /\t/) + if (f[nf] == region) { + print f[4] + } + } + } '` ;; *) -- 2.39.0
participants (1)
-
Paul Eggert