History

configure: avoid non-POSIX: local var=...

The vast majority of shells do support "local", but not all, notably AT&T ksh (default sh in illumos-based distros and Solaris), but also some other POSIX-compliant shells, so remove "local". print_str(), print_num() are modified trivially. default() now uses standard "Assign Default Value" - same semantics, and works in all shells (and POSIX). default_conf() is identical to before, but it had and still has few minor issues, which will be addressed in a future commit.

Avi Halachmi (:avih) committed 1 year ago

Commit 6f4b3841 parent 05ebe491 file · +9 −12Browse files

Unified · Split

configure+9−12
@@ -206,17 +206,14 @@ EOF · 205 unmodified lines
206exit 1206exit 1
207}207}
208 208
209default() # set variable unless already set209default() # set variable unless already set and not empty
210{210{
211 local v211 test -n "$2" && eval : \${$1:=\$2} # ': ${foo:=$2}'
212 eval v=\"\$$1\"
213 test -z "$v" && test -n "$2" && eval $1=\"$2\"
214}212}
215 213
216default_conf() # add to confvars unless already present214default_conf() # add to confvars unless already present
217{215{
218 local v=${1%=*}216 test "${confvars%${1%=*}*}" = "${confvars}" && confvars="$confvars $1"
219 test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
220}217}
221 218
222if test -z "${source_path#.}" ; then219if test -z "${source_path#.}" ; then
@@ -565,20 +562,20 @@ else · 342 unmodified lines
565 echo 'TOPSRC=$(TOP)' >>config.mak562 echo 'TOPSRC=$(TOP)' >>config.mak
566fi563fi
567 564
565# $1: macro name, $2: val to set - quoted [, $3: non-empty for #ifndef]
568print_str() {566print_str() {
569 local v="$2"567 if test -n "$2"; then
570 if test -n "$v"; then
571 test -n "$3" && echo "#ifndef $1" >> $TMPH568 test -n "$3" && echo "#ifndef $1" >> $TMPH
572 echo "#define $1 \"$v\"" >> $TMPH569 echo "#define $1 \"$2\"" >> $TMPH
573 test -n "$3" && echo "#endif" >> $TMPH570 test -n "$3" && echo "#endif" >> $TMPH
574 fi571 fi
575}572}
576 573
574# $1: macro name, $2: val to set [, $3: non-empty for #ifndef]
577print_num() {575print_num() {
578 local v="$2"576 if test -n "$2"; then
579 if test -n "$v"; then
580 test -n "$3" && echo "#ifndef $1" >> $TMPH577 test -n "$3" && echo "#ifndef $1" >> $TMPH
581 echo "#define $1 $v" >> $TMPH578 echo "#define $1 $2" >> $TMPH
582 test -n "$3" && echo "#endif" >> $TMPH579 test -n "$3" && echo "#endif" >> $TMPH
583 fi580 fi
584}581}

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