From f37005b729065f0e4ff6bfa99e5410ebb210cd60 Mon Sep 17 00:00:00 2001
From: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Date: Mon, 27 Jan 2020 15:15:40 +0000
Subject: Initial scripts compatible with Dash (minimalistic POSIX)

Until now, the initial project scripts were primarily tested with GNU
Bash. But Bash is not generally available on all systems (it has many
features beyond POSIX). Because of this, effectively we were imposing the
requirement on the user that they must have Bash installed. We recently
started this with setting the shebang of `project' and
`reproduce/software/bash/configure.sh' to `/bin/sh'. After doing so, Raul
and Gaspar reported an error on their systems.

To fix the problem, I installed Dash (a minimalist POSIX-compliant shell)
on my computer and temporarily set the shebangs to `/bin/dash', ran the
project configuration step and fixed all issues that came up. With this
commit, it can go all the way to building GCC on my system's Dash. After
this stage (when `high-level.mk' is called), there is no problem, because
we have our own version of GNU Bash and that installed version is used.
Probably some more issues still remain and will hopefully be found in the
future.

While doing this, I also noticed the following two minor issues:

 - The `./project configure' option `--input-dir' was not recognized
   because it was mistakenly checking `--inputdir'. It has been corrected.

 - The test C programs now use the `<<EOF' method instead of `echo'.

 - In `basic.mk', the extra space between `syspath' and `:=' was removed
   (it was an ancient relic!).
---
 project | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'project')

diff --git a/project b/project
index 264895a..89361ae 100755
--- a/project
+++ b/project
@@ -144,7 +144,7 @@ func_operation_set() {
     fi
 }
 
-while [[ $# -gt 0 ]]
+while [ $# -gt 0 ]
 do
  case $1 in
   # Main operation.
@@ -160,8 +160,8 @@ do
   -e*|--existing-conf=*) on_off_option_error --existing-conf -e;;
   --host-cc)             host_cc=1;                                                                shift;;
   --host-cc=*)           on_off_option_error --host-cc;;
-  -i|--inputdir)         input_dir="$2";                             check_v "$1" "$input_dir";    shift;shift;;
-  -i=*|--inputdir=*)     input_dir="${1#*=}";                        check_v "$1" "$input_dir";    shift;;
+  -i|--input-dir)        input_dir="$2";                             check_v "$1" "$input_dir";    shift;shift;;
+  -i=*|--input-dir=*)    input_dir="${1#*=}";                        check_v "$1" "$input_dir";    shift;;
   -i*)                   input_dir=$(echo    "$1" | sed -e's/-i//'); check_v "$1" "$input_dir";    shift;;
   -m|--minmapsize)       minmapsize="$2";                            check_v "$1" "$minmapsize";   shift;shift;;
   -m=*|--minmapsize=*)   minmapsize="${1#*=}";                       check_v "$1" "$minmapsize";   shift;;
@@ -209,8 +209,8 @@ if ! [ x$check_config = x ]; then
     # Find the color option to pass to `ls'. Note that `--color' (for GNU
     # Coreutils `ls') should be checked first because it also has `-G', but
     # for something else.
-    if   ls --color &> /dev/null; then coloropt="--color=auto"
-    elif ls -G      &> /dev/null; then coloropt="-G"
+    if   ls --color 2> /dev/null > /dev/null; then coloropt="--color=auto"
+    elif ls -G      2> /dev/null > /dev/null; then coloropt="-G"
     else                               coloropt=""
     fi
 
-- 
cgit v1.2.1