Skip to content

Commit eba4316

Browse files
committed
Avoid an awk invocation via $'...'
* NEWS: Mention this. * tzselect.ksh (CUNEIFORM_SIGN_URU_TIMES_KI): New variable. This uses $'...' if available, which avoids an awk invocation in the typical case when Bash is used. $'...' is available in ksh93, bash-2.0 (1996), and any shell conforming to POSIX.1-2024. (translit): Use it.
1 parent 36479a8 commit eba4316

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

NEWS

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ Unreleased, experimental changes
6161
-DSUPPORT_POSIX2008 to CFLAGS.
6262

6363
tzselect now assumes POSIX.2-1992 or later, as practical porting
64-
targets now all support this.
64+
targets now all support this. Also, tzselect uses some features
65+
from POSIX.1-2024 if available.
6566

6667
Changes to build procedure
6768

tzselect.ksh

+7-5
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ esac
163163

164164
# translit=true to try transliteration.
165165
# This is false if U+12345 CUNEIFORM SIGN URU TIMES KI has length 1
166-
# which means awk (and presumably the shell) do not need transliteration.
167-
if $AWK 'BEGIN { u12345 = "\360\222\215\205"; exit length(u12345) == 1 }'; then
168-
translit=true
169-
else
170-
translit=false
166+
# which means the shell and (presumably) awk do not need transliteration.
167+
# It is true if the byte string has some other length in characters, or
168+
# if this is a POSIX.1-2017 or earlier shell that does not support $'...'.
169+
CUNEIFORM_SIGN_URU_TIMES_KI=$'\360\222\215\205'
170+
if test ${#CUNEIFORM_SIGN_URU_TIMES_KI} = 1
171+
then translit=false
172+
else translit=true
171173
fi
172174

173175
# Read into shell variable $1 the contents of file $2.

0 commit comments

Comments
 (0)