configure improvements pasted by mario-goulart on Tue Jul 9 21:43:05 2024

diff --git a/configure b/configure
index fc67ace5..6e10d5c9 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# configuation script for the CHICKEN build process
+# configuration script for the CHICKEN build process
 #
 # Copyright (c) 2024, The CHICKEN Team
 # All rights reserved.
@@ -28,7 +28,6 @@
 prefix=/usr/local
 debug=
 static=
-shared=1
 host=
 target=
 tprefix=
@@ -40,13 +39,13 @@ linker=
 platform=
 chicken=
 pobjs=
-mkcmd=make
+mkcmd="make"
 
 usage () {
-    echo "usage: configure [--help] [--prefix DIRECTORY] [--platform PLATFORM] [--chicken PROGRAMNAME] [--debugbuild] [--staticbuild] [--disable-shared] [--host HOSTSYSTEM] [--target TARGETSYSTEM] [--program-prefix PREFIX] [--program-suffix SUFFIX] [--target-prefix DIRECTORY] [--srcdir DIRECTORY] [--vardir DIRECTORY] [--c-compiler PROGRAMNAME] [--linker PROGRAMNAME] [--profile-objects OBJECTLIST]"
+    echo "usage: configure [--help] [--prefix DIRECTORY] [--platform PLATFORM | list] [--chicken PROGRAMNAME] [--debugbuild] [--staticbuild] [--disable-shared] [--host HOSTSYSTEM] [--target TARGETSYSTEM] [--program-prefix PREFIX] [--program-suffix SUFFIX] [--target-prefix DIRECTORY] [--srcdir DIRECTORY] [--vardir DIRECTORY] [--c-compiler PROGRAMNAME] [--linker PROGRAMNAME] [--profile-objects OBJECTLIST]"
     echo
     echo "consult the README file for more information."
-    exit $1
+    exit "$1"
 }
 
 while [ -n "$1" ]; do
@@ -56,21 +55,21 @@ while [ -n "$1" ]; do
         -h|-help|--help)
             usage 0;;
         --chicken=*)
-            chicken=$(echo $arg | sed 's/^[^=]*=//');;
+            chicken=${arg#--chicken=};;
         --chicken)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             chicken="$1"
             shift;;
         --prefix=*)
-            prefix=$(echo $arg | sed 's/^[^=]*=//');;
+            prefix=${arg#--prefix=};;
         --prefix)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             prefix="$1"
             shift;;
         --platform=*)
-            platform=$(echo $arg | sed 's/^[^=]*=//');;
+            platform=${arg#--platform=};;
         --platform)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             platform="$1"
             shift;;
         --debugbuild)
@@ -78,157 +77,157 @@ while [ -n "$1" ]; do
         --staticbuild|--disable-shared)
             static=1;;
         --host=*)
-            host=$(echo $arg | sed 's/^[^=]*=//');;
+            host=${arg#--host};;
         --host)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             host="$1"
             shift;;
         --target=*)
-            target=$(echo $arg | sed 's/^[^=]*=//');;
+            target=${arg#--target=};;
         --target)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             target="$1"
             shift;;
         --program-prefix=*)
-            pprefix=$(echo $arg | sed 's/^[^=]*=//');;
+            pprefix=${arg#--program-prefix=};;
         --program-prefix)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             pprefix="$1"
             shift;;
         --program-suffix=*)
-            psuffix=$(echo $arg | sed 's/^[^=]*=//');;
+            psuffix=${arg#--program-suffix=};;
         --program-suffix)
             test -z "$1" && usage 1
             psuffix="$1"
             shift;;
         --target-prefix=*)
-            tprefix=$(echo $arg | sed 's/^[^=]*=//');;
+            tprefix=${arg#--target-prefix=};;
         --target-prefix)
             test -z "$1" && usage 1
             tprefix="$1"
             shift;;
         --srcdir=*)
-            srcdir=$(echo $arg | sed 's/^[^=]*=//');;
+            srcdir=${arg#--srcdir=};;
         --srcdir)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             srcdir="$1"
             shift;;
         --vardir=*)
-            vardir=$(echo $arg | sed 's/^[^=]*=//');;
+            vardir=${arg#--vardir=};;
         --vardir)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             vardir="$1"
             shift;;
         --profile-objects=*)
-            pobjs=$(echo $arg | sed 's/^[^=]*=//');;
+            pobjs=${arg#--profile-objects=};;
         --profile-objects)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             pobjs="$1"
             shift;;
         --c-compiler=*)
-            CC=$(echo $arg | sed 's/^[^=]*=//');;
+            CC=${arg#--c-compiler=};;
         --c-compiler)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             CC="$1";;
         --linker=*)
-            linker=$(echo $arg | sed 's/^[^=]*=//');;
+            linker=${arg#--linker=};;
         --linker)
-            test -z "$1" && usage 1
+            test -z "$1" && usage 1 >&2
             linker="$1"
             shift;;
         *)
-            usage 1;;
+            usage 1 >&2;;
     esac
 done
 
-if [ "$platform" == list ]; then
+if [ "$platform" = list ]; then
     echo "available platforms:"
     echo
     for mf in Makefile.*; do
-        echo "    " $(echo $mf | sed 's/^[^.]*\.//')
+        echo "     ${mf#Makefile.}"
     done
     echo
     exit
 fi
 
 if [ -z "$platform" ]; then
-printf 'detecting platform ... '
+    printf 'detecting platform ... '
 
-# Detect the PLATFORM with uname.
-# Based on Chibi Scheme auto-detector
-# Heavily revamped by John Cowan
-# Moved into configure script by Felix Winkelmann
-# Copyright (c) 2009-2018 Alex Shinn, John Cowan
-# BSD license at 
+    # Detect the PLATFORM with uname.
+    # Based on Chibi Scheme auto-detector
+    # Heavily revamped by John Cowan
+    # Moved into configure script by Felix Winkelmann
+    # Copyright (c) 2009-2018 Alex Shinn, John Cowan
+    # BSD license at 
 
-# Now we can use uname tests
-uname_s=$(uname)
-uname_o=$(uname -o 2>/dev/null)
+    # Now we can use uname tests
+    uname_s=$(uname)
+    uname_o=$(uname -o 2>/dev/null)
 
-case "$uname_s" in
-    Darwin)
-        platform=macosx;;
-    *BSD)
-        platform=bsd;;
-    DragonFly)
-        platform=bsd;;
-    Windows_NT)
-       platform=mingw
-       case "$prefix" in
-           [a-zA-Z]:*)
-           	;;
-           *)
-           	echo "on Windows, the prefix must contain a drive letter" >&2
-           	exit 1;;
-         esac;;
-    SunOS)
-        platform=solaris;;
-    BeOS)
-        platform=haiku;;
-    Haiku)
-        platform=haiku;;
-    GNU)
-        platform=hurd;;
-    AIX)
-        platform=aix;;
-    *)
-        case "$uname_o" in
-            Cygwin)
-                platform=cygwin;;
-            Android)
-                platform=android;;
-            GNU/Linux)
-                platform=linux;;
-            Linux)
-                platform=linux;;
-            *)
-             	  echo
-                echo "unable to figure out platform" >&2
-                exit 1;;
-        esac;;
-esac
-echo $platform
+    case "$uname_s" in
+        Darwin)
+            platform=macosx;;
+        *BSD)
+            platform=bsd;;
+        DragonFly)
+            platform=bsd;;
+        Windows_NT)
+            platform=mingw
+            case "$prefix" in
+                [a-zA-Z]:*)
+                ;;
+                *)
+                    echo "on Windows, the prefix must contain a drive letter" >&2
+                    exit 1;;
+            esac;;
+        SunOS)
+            platform=solaris;;
+        BeOS)
+            platform=haiku;;
+        Haiku)
+            platform=haiku;;
+        GNU)
+            platform=hurd;;
+        AIX)
+            platform=aix;;
+        *)
+            case "$uname_o" in
+                Cygwin)
+                    platform=cygwin;;
+                Android)
+                    platform=android;;
+                GNU/Linux)
+                    platform=linux;;
+                Linux)
+                    platform=linux;;
+                *)
+                    echo
+                    echo "unable to figure out platform" >&2
+                    exit 1;;
+            esac;;
+    esac
+    echo "$platform"
 fi
 
-cccmd=gcc
+cccmd="gcc"
 if [ "$platform" = "bsd" ]; then
-    cccmd=cc
+    cccmd="cc"
     if command -v gmake >/dev/null; then
-        mkcmd=gmake
+        mkcmd="gmake"
     else
-        echo 'GNU make is required but does not seem to be available' >&2
+        echo "GNU make is required but does not seem to be available" >&2
         exit 1
     fi
 fi
 
-echo 'installation prefix:' $prefix
-test -n "$chicken" && echo 'bootstrap chicken:' $chicken
+echo "installation prefix: $prefix"
+test -n "$chicken" && echo "bootstrap chicken: $chicken"
 
 test -n "$CC" && cccmd="$CC"
 
 printf "testing C compiler (%s) ... " "$cccmd"
 tmpc="$(mktemp).c"
-cat > $tmpc < "$tmpc" </dev/null; then
@@ -240,38 +239,38 @@ if command -v $cccmd >/dev/null; then
         else
             rm -f "${tmpc}.out"
             echo
-            echo $cccmd 'does not seem to produce working executable' >&2
+            echo "$cccmd does not seem to produce working executables" >&2
             exit 1
         fi
     else
         rm -f "$tmpc" "${tmpc}.out"
         echo
-        echo $cccmd 'does not seem to work' >&2
+        echo "$cccmd does not seem to work" >&2
         exit 1
     fi
 else
     echo
-    echo 'can not find' $cccmd >&2
+    echo "cannot find $cccmd" >&2
     exit 1
 fi
 
-echo '# GENERATED BY configure' > config.make
-echo 'PLATFORM ?=' $platform >> config.make
-echo 'PREFIX ?=' $prefix >> config.make
-test -n "$debug" && echo 'DEBUGBUILD ?= 1' >> config.make
-test -n "$static" && echo 'STATICBUILD ?= 1' >> config.make
-test -n "$CC" && echo 'C_COMPILER ?=' $cccmd >> config.make
-test -n "$linker" && echo 'LINKER ?=' $linker >> config.make
-test -n "$CFLAGS" && echo 'C_COMPILER_OPTIMIZATION_OPTIONS ?=' $CFLAGS >> config.make
-test -n "$host" && echo 'HOSTSYSTEM ?=' $host >> config.make
-test -n "$target" && echo 'TARGETSYSTEM ?=' $target >> config.make
-test -n "$pprefix" && echo 'PROGRAM_PREFIX ?=' $pprefix >> config.make
-test -n "$psuffix" && echo 'PROGRAM_SUFFIX ?=' $psuffix >> config.make
-test -n "$tprefix" && echo 'TARGET_PREFIX ?=' $tprefix >> config.make
-test -n "$srcdir" && echo 'SRCDIR ?=' $srcdir >> config.make
-test -n "$vardir" && echo 'VARDIR ?=' $vardir >> config.make
-test -n "$chicken" && echo 'CHICKEN ?=' $chicken >> config.make
-test -n "$pobjs" && echo 'PROFILE_OBJECTS ?=' $pobjs >> config.make
+echo "# GENERATED BY configure" > config.make
+echo "PLATFORM ?= $platform" >> config.make
+echo "PREFIX ?= $prefix" >> config.make
+test -n "$debug" && echo "DEBUGBUILD ?= 1" >> config.make
+test -n "$static" && echo "STATICBUILD ?= 1" >> config.make
+test -n "$CC" && echo "C_COMPILER ?= $cccmd" >> config.make
+test -n "$linker" && echo "LINKER ?= $linker" >> config.make
+test -n "$CFLAGS" && echo "C_COMPILER_OPTIMIZATION_OPTIONS ?= $CFLAGS" >> config.make
+test -n "$host" && echo "HOSTSYSTEM ?= $host" >> config.make
+test -n "$target" && echo "TARGETSYSTEM ?= $target" >> config.make
+test -n "$pprefix" && echo "PROGRAM_PREFIX ?= $pprefix" >> config.make
+test -n "$psuffix" && echo "PROGRAM_SUFFIX ?= $psuffix" >> config.make
+test -n "$tprefix" && echo "TARGET_PREFIX ?= $tprefix" >> config.make
+test -n "$srcdir" && echo "SRCDIR ?= $srcdir" >> config.make
+test -n "$vardir" && echo "VARDIR ?= $vardir" >> config.make
+test -n "$chicken" && echo "CHICKEN ?= $chicken" >> config.make
+test -n "$pobjs" && echo "PROFILE_OBJECTS ?= $pobjs" >> config.make
 
 echo
 echo "now run ${mkcmd} to build the system"

shellcheck warnings added by mario-goulart on Tue Jul 9 21:45:45 2024

$ shellcheck configure

In configure line 233:
if command -v $cccmd >/dev/null; then
              ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if command -v "$cccmd" >/dev/null; then


In configure line 234:
    if $cccmd "$tmpc" $CFLAGS -o "${tmpc}.out"; then
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if $cccmd "$tmpc" "$CFLAGS" -o "${tmpc}.out"; then

For more information:
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...