History

configure: avoid non-POSIX: test ... -a/-o ...

Shells do support those, and typically simple forms do work, but these were removed in POSIX 2024 because they are notoriously hard to parse correctly, and shells don't always agree on the result. Instead, use standard forms which all shells support identically. Extreme high level overview of quotes in POSIX shell: - WORDs without $... or glob don't need quotes (echo, =, no, x86, ...). - a= b=foo c=$... and case $d in ... all don't need quotes. - IFS/glob affect command and arguments (not assignments or case..in): - IFS only splits direct result of $..., quotes will prevent that. - Glob then splits/matches *?[] and quotes will prevent that. POSIX "test" (see Application Usage), and shell language (quotes): https://pubs.opengroup.org/onlinepubs/9799919799/utilities/test.html https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html My own quick guide: https://gist.github.com/avih/6752ad1e20b334b56fef120cd09c766e

Avi Halachmi (:avih) committed 1 year ago

Commit 05ebe491 parent cea857b1 file · +10 −9Browse files

Unified · Split

configure+10−9
@@ -210,7 +210,7 @@ default() # set variable unless already set · 209 unmodified lines
210210 {
211211 local v
212212 eval v=\"\$$1\"
213− test -z "$v" -a -n "$2" && eval $1=\"$2\"
213+ test -z "$v" && test -n "$2" && eval $1=\"$2\"
214214 }
215215
216216 default_conf() # add to confvars unless already present
@@ -219,7 +219,7 @@ default_conf() # add to confvars unless already present · 2 unmodified lines
219219 test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
220220 }
221221
222−if test -z "$source_path" -o "$source_path" = "." ; then
222+if test -z "${source_path#.}" ; then
223223 source_path=$(pwd)
224224 source_path_used="no"
225225 else
@@ -254,9 +254,10 @@ fi · 28 unmodified lines
254254 default cpu "$cpu_sys"
255255
256256 # check for crpss build
257−if test "$cpu" != "$cpu_sys" \
258− -o "$targetos" != "$buildos" \
259− -o -n "$cross_prefix" ; then
257+if test "$cpu" != "$cpu_sys" ||
258+ test "$targetos" != "$buildos" ||
259+ test -n "$cross_prefix"
260+then
260261 build_cross="yes"
261262 cc="${cross_prefix}${cc}"
262263 ar="${cross_prefix}${ar}"
@@ -337,7 +338,7 @@ case $targetos in · 74 unmodified lines
337338 fi
338339 fi
339340 # on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely
340− if test "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then
341+ if test "$cpu" = x86_64 && test "$cpu_sys" = arm64; then
341342 CFLAGS="$CFLAGS -arch $cpu"
342343 LDFLAGS="$LDFLAGS -arch $cpu"
343344 fi
@@ -422,17 +423,17 @@ if test -z "$build_cross"; then · 78 unmodified lines
422423 _triplet="$($CONFTEST triplet)"
423424 fi
424425 if test "$mingw32" = "no" ; then
425− if test -z "$triplet" -a -n "$_triplet"; then
426+ if test -z "$triplet" && test -n "$_triplet"; then
426427 if test -f "/usr/lib/$_triplet/crti.o"; then
427428 triplet="$_triplet"
428429 fi
429430 fi
430431 if test -z "$triplet"; then
431− if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then
432+ case $cpu in x86_64|arm64|riscv64)
432433 if test -f "/usr/lib64/crti.o" ; then
433434 tcc_lddir="lib64"
434435 fi
435− fi
436+ esac
436437 fi
437438 if test "$suggest" = "yes"; then
438439 if test -f "/lib/ld-uClibc.so.0" ; then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t