On 7/3/21, Jacob Bachmeyer <jcb62...@gmail.com> wrote:
> Ozkan Sezer wrote:
>> The attached patch replaces a handful of POSIX $(xx) with classic `xx`
>> in config.sub. This is in line with the recent config.guess change i.e.
>> commit d70c4fa934de:
>> http://git.savannah.gnu.org/gitweb/?p=config.git;a=commit;h=d70c4fa934de164178054c3a60aaa0024ed07c91
>>
>> --
>> O.S.
>>
>
> While doing this, also normalizing the quoting in the `echo FOO | sed
> ...` would be nice.  Some cases quote the argument to echo and some do
> not.  At runtime it probably does not matter because the substituted
> values will never contain whitespace, but quoting them all would make
> shellcheck more useful.
>
> Also see patch 5 in the recent "v2" series for the marker line to
> prevent shellcheck from complaining about backticks.  It must be placed
> before the first executable line (the timestamp variable assignment) for
> shellcheck to apply it to the entire script.
>
>
> -- Jacob

Done, as best as I can: Attached patches.

$ make check-sub
cd testsuite && bash config-sub.sh
PASS: config.sub checks (864 tests)
PASS: config.sub idempotency checks (801 tests)
PASS: config.sub canonicalise each config.guess testcase (136 tests)

shellcheck barfs with SC1117 in config.guess, but no errors with
config.sub.

Off-topic: check-sub fails on my old setup with CentOS-6.10:
config-sub.sh: line 12: shopt: lastpipe: invalid shell option name

--
O.S.
From f9253dd29ad995f6128c224fcf190ac8ddca6a92 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sez...@users.sourceforge.net>
Date: Fri, 2 Jul 2021 08:55:50 +0300
Subject: [PATCH] config.sub: go back to backtick substitutions

Signed-off-by: Ozkan Sezer <sez...@users.sourceforge.net>
---
 config.sub |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/config.sub b/config.sub
index b470211..3450580 100755
--- a/config.sub
+++ b/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2021 Free Software Foundation, Inc.
 
-timestamp='2021-06-03'
+timestamp='2021-07-02'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ timestamp='2021-06-03'
 #	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 # It is wrong to echo any other type of specification.
 
-me=$(echo "$0" | sed -e 's,.*/,,')
+me=`echo "$0" | sed -e 's,.*/,,'`
 
 usage="\
 Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
@@ -769,22 +769,22 @@ case $basic_machine in
 		vendor=hp
 		;;
 	i*86v32)
-		cpu=$(echo "$1" | sed -e 's/86.*/86/')
+		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
 		basic_os=sysv32
 		;;
 	i*86v4*)
-		cpu=$(echo "$1" | sed -e 's/86.*/86/')
+		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
 		basic_os=sysv4
 		;;
 	i*86v)
-		cpu=$(echo "$1" | sed -e 's/86.*/86/')
+		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
 		basic_os=sysv
 		;;
 	i*86sol2)
-		cpu=$(echo "$1" | sed -e 's/86.*/86/')
+		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
 		basic_os=solaris2
 		;;
@@ -917,7 +917,7 @@ case $basic_machine in
 		;;
 	leon-*|leon[3-9]-*)
 		cpu=sparc
-		vendor=$(echo "$basic_machine" | sed 's/-.*//')
+		vendor=`echo "$basic_machine" | sed 's/-.*//'`
 		;;
 
 	*-*)
@@ -1084,7 +1084,7 @@ case $cpu-$vendor in
 		cpu=mipsisa64sb1el
 		;;
 	sh5e[lb]-*)
-		cpu=$(echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/')
+		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
 		;;
 	spur-*)
 		cpu=spur
@@ -1102,7 +1102,7 @@ case $cpu-$vendor in
 		cpu=x86_64
 		;;
 	xscale-* | xscalee[bl]-*)
-		cpu=$(echo "$cpu" | sed 's/^xscale/arm/')
+		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
 		;;
 	arm64-*)
 		cpu=aarch64
@@ -1292,15 +1292,15 @@ then
 case $basic_os in
 	gnu/linux*)
 		kernel=linux
-		os=$(echo $basic_os | sed -e 's|gnu/linux|gnu|')
+		os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'`
 		;;
 	os2-emx)
 		kernel=os2
-		os=$(echo $basic_os | sed -e 's|os2-emx|emx|')
+		os=`echo $basic_os | sed -e 's|os2-emx|emx|'`
 		;;
 	nto-qnx*)
 		kernel=nto
-		os=$(echo $basic_os | sed -e 's|nto-qnx|qnx|')
+		os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'`
 		;;
 	*-*)
 		# shellcheck disable=SC2162
@@ -1311,11 +1311,11 @@ EOF
 	# Default OS when just kernel was specified
 	nto*)
 		kernel=nto
-		os=$(echo $basic_os | sed -e 's|nto|qnx|')
+		os=`echo $basic_os | sed -e 's|nto|qnx|'`
 		;;
 	linux*)
 		kernel=linux
-		os=$(echo $basic_os | sed -e 's|linux|gnu|')
+		os=`echo $basic_os | sed -e 's|linux|gnu|'`
 		;;
 	*)
 		kernel=
@@ -1336,7 +1336,7 @@ case $os in
 		os=cnk
 		;;
 	solaris1 | solaris1.*)
-		os=$(echo $os | sed -e 's|solaris1|sunos4|')
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
 		;;
 	solaris)
 		os=solaris2
@@ -1365,7 +1365,7 @@ case $os in
 		os=sco3.2v4
 		;;
 	sco3.2.[4-9]*)
-		os=$(echo $os | sed -e 's/sco3.2./sco3.2v/')
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
 		;;
 	sco*v* | scout)
 		# Don't match below
@@ -1395,7 +1395,7 @@ case $os in
 		os=lynxos
 		;;
 	mac[0-9]*)
-		os=$(echo "$os" | sed -e 's|mac|macos|')
+		os=`echo "$os" | sed -e 's|mac|macos|'`
 		;;
 	opened*)
 		os=openedition
@@ -1404,10 +1404,10 @@ case $os in
 		os=os400
 		;;
 	sunos5*)
-		os=$(echo "$os" | sed -e 's|sunos5|solaris2|')
+		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
 		;;
 	sunos6*)
-		os=$(echo "$os" | sed -e 's|sunos6|solaris3|')
+		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
 		;;
 	wince*)
 		os=wince
@@ -1441,7 +1441,7 @@ case $os in
 		;;
 	# Preserve the version number of sinix5.
 	sinix5.*)
-		os=$(echo $os | sed -e 's|sinix|sysv|')
+		os=`echo $os | sed -e 's|sinix|sysv|'`
 		;;
 	sinix*)
 		os=sysv4
-- 
1.7.1

From 30901d96296fd7d9b5394f405e47fba29a0dfaae Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sez...@users.sourceforge.net>
Date: Sat, 3 Jul 2021 11:05:40 +0300
Subject: [PATCH] config.sub: normalize the quoting in the `echo FOO | sed ...`

As suggested by Jacob Bachmeyer.
Signed-off-by: Ozkan Sezer <sez...@users.sourceforge.net>
---
 config.sub |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config.sub b/config.sub
index 3450580..f834899 100755
--- a/config.sub
+++ b/config.sub
@@ -1292,15 +1292,15 @@ then
 case $basic_os in
 	gnu/linux*)
 		kernel=linux
-		os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'`
+		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
 		;;
 	os2-emx)
 		kernel=os2
-		os=`echo $basic_os | sed -e 's|os2-emx|emx|'`
+		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
 		;;
 	nto-qnx*)
 		kernel=nto
-		os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'`
+		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
 		;;
 	*-*)
 		# shellcheck disable=SC2162
@@ -1311,11 +1311,11 @@ EOF
 	# Default OS when just kernel was specified
 	nto*)
 		kernel=nto
-		os=`echo $basic_os | sed -e 's|nto|qnx|'`
+		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
 		;;
 	linux*)
 		kernel=linux
-		os=`echo $basic_os | sed -e 's|linux|gnu|'`
+		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
 		;;
 	*)
 		kernel=
@@ -1336,7 +1336,7 @@ case $os in
 		os=cnk
 		;;
 	solaris1 | solaris1.*)
-		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
 		;;
 	solaris)
 		os=solaris2
@@ -1365,7 +1365,7 @@ case $os in
 		os=sco3.2v4
 		;;
 	sco3.2.[4-9]*)
-		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
 		;;
 	sco*v* | scout)
 		# Don't match below
@@ -1441,7 +1441,7 @@ case $os in
 		;;
 	# Preserve the version number of sinix5.
 	sinix5.*)
-		os=`echo $os | sed -e 's|sinix|sysv|'`
+		os=`echo "$os" | sed -e 's|sinix|sysv|'`
 		;;
 	sinix*)
 		os=sysv4
-- 
1.7.1

From 226fa220e10c32ff62c6b1003982e3c300e8c82f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sez...@users.sourceforge.net>
Date: Sat, 3 Jul 2021 11:05:56 +0300
Subject: [PATCH] config.sub: disable shellcheck SC2006 / SC2268 warnings

As suggested by Jacob Bachmeyer.
Signed-off-by: Ozkan Sezer <sez...@users.sourceforge.net>
---
 config.sub |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/config.sub b/config.sub
index f834899..6a07928 100755
--- a/config.sub
+++ b/config.sub
@@ -2,6 +2,8 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2021 Free Software Foundation, Inc.
 
+# shellcheck disable=SC2006,SC2268
+
 timestamp='2021-07-02'
 
 # This file is free software; you can redistribute it and/or modify it
-- 
1.7.1

Reply via email to