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
206206 exit 1
207207 }
208208
209−default() # set variable unless already set
209+default() # set variable unless already set and not empty
210210 {
211− local v
212− eval v=\"\$$1\"
213− test -z "$v" && test -n "$2" && eval $1=\"$2\"
211+ test -n "$2" && eval : \${$1:=\$2} # ': ${foo:=$2}'
214212 }
215213
216214 default_conf() # add to confvars unless already present
217215 {
218− local v=${1%=*}
219− test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
216+ test "${confvars%${1%=*}*}" = "${confvars}" && confvars="$confvars $1"
220217 }
221218
222219 if test -z "${source_path#.}" ; then
@@ -565,20 +562,20 @@ else · 342 unmodified lines
565562 echo 'TOPSRC=$(TOP)' >>config.mak
566563 fi
567564
565+# $1: macro name, $2: val to set - quoted [, $3: non-empty for #ifndef]
568566 print_str() {
569− local v="$2"
570− if test -n "$v"; then
567+ if test -n "$2"; then
571568 test -n "$3" && echo "#ifndef $1" >> $TMPH
572− echo "#define $1 \"$v\"" >> $TMPH
569+ echo "#define $1 \"$2\"" >> $TMPH
573570 test -n "$3" && echo "#endif" >> $TMPH
574571 fi
575572 }
576573
574+# $1: macro name, $2: val to set [, $3: non-empty for #ifndef]
577575 print_num() {
578− local v="$2"
579− if test -n "$v"; then
576+ if test -n "$2"; then
580577 test -n "$3" && echo "#ifndef $1" >> $TMPH
581− echo "#define $1 $v" >> $TMPH
578+ echo "#define $1 $2" >> $TMPH
582579 test -n "$3" && echo "#endif" >> $TMPH
583580 fi
584581 }

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