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
210{210{
211 local v211 local v
212 eval v=\"\$$1\"212 eval v=\"\$$1\"
213 test -z "$v" -a -n "$2" && eval $1=\"$2\"213 test -z "$v" && test -n "$2" && eval $1=\"$2\"
214}214}
215 215
216default_conf() # add to confvars unless already present216default_conf() # add to confvars unless already present
@@ -219,7 +219,7 @@ default_conf() # add to confvars unless already present · 2 unmodified lines
219 test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"219 test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
220}220}
221 221
222if test -z "$source_path" -o "$source_path" = "." ; then222if test -z "${source_path#.}" ; then
223 source_path=$(pwd)223 source_path=$(pwd)
224 source_path_used="no"224 source_path_used="no"
225else225else
@@ -254,9 +254,10 @@ fi · 28 unmodified lines
254default cpu "$cpu_sys"254default cpu "$cpu_sys"
255 255
256# check for crpss build256# check for crpss build
257if test "$cpu" != "$cpu_sys" \257if test "$cpu" != "$cpu_sys" ||
258 -o "$targetos" != "$buildos" \258 test "$targetos" != "$buildos" ||
259 -o -n "$cross_prefix" ; then259 test -n "$cross_prefix"
260then
260 build_cross="yes"261 build_cross="yes"
261 cc="${cross_prefix}${cc}"262 cc="${cross_prefix}${cc}"
262 ar="${cross_prefix}${ar}"263 ar="${cross_prefix}${ar}"
@@ -337,7 +338,7 @@ case $targetos in · 74 unmodified lines
337 fi338 fi
338 fi339 fi
339 # on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely340 # 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"; then341 if test "$cpu" = x86_64 && test "$cpu_sys" = arm64; then
341 CFLAGS="$CFLAGS -arch $cpu"342 CFLAGS="$CFLAGS -arch $cpu"
342 LDFLAGS="$LDFLAGS -arch $cpu"343 LDFLAGS="$LDFLAGS -arch $cpu"
343 fi344 fi
@@ -422,17 +423,17 @@ if test -z "$build_cross"; then · 78 unmodified lines
422 _triplet="$($CONFTEST triplet)"423 _triplet="$($CONFTEST triplet)"
423 fi424 fi
424 if test "$mingw32" = "no" ; then425 if test "$mingw32" = "no" ; then
425 if test -z "$triplet" -a -n "$_triplet"; then426 if test -z "$triplet" && test -n "$_triplet"; then
426 if test -f "/usr/lib/$_triplet/crti.o"; then427 if test -f "/usr/lib/$_triplet/crti.o"; then
427 triplet="$_triplet"428 triplet="$_triplet"
428 fi429 fi
429 fi430 fi
430 if test -z "$triplet"; then431 if test -z "$triplet"; then
431 if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then432 case $cpu in x86_64|arm64|riscv64)
432 if test -f "/usr/lib64/crti.o" ; then433 if test -f "/usr/lib64/crti.o" ; then
433 tcc_lddir="lib64"434 tcc_lddir="lib64"
434 fi435 fi
435 fi436 esac
436 fi437 fi
437 if test "$suggest" = "yes"; then438 if test "$suggest" = "yes"; then
438 if test -f "/lib/ld-uClibc.so.0" ; then439 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