oops, I tried adding a redirect to |stderr| last second but got the syntax wrong. Also forgot to run |help2man| and update the timestamp.

Oh and to clarify: what "fails" silently are configuration names alike |arch-os-obj| (eg |sparc-sol2-elf64|). Using a kernel name that is recognized in a three part tuple fails correctly.

--
- Lily A. N.
From 9fa1914234a6e43dab0a2934d2f2e93e9100aea2 Mon Sep 17 00:00:00 2001
From: "Lilith N." <minek...@dimension.sh>
Date: Thu, 20 Mar 2025 19:30:14 +0100
Subject: [PATCH] config.sub: sol2 and UX improvements

- added `sol2%` as an alias to `solaris2%`.
- improve error message for inputs which provide
  both an OS and/or kernel and a Machine code format.
- add a VERBOSE feature, allowing a user to inspect how a configuration
  name is understood.
---
 config.sub                | 22 ++++++++++++++++++++--
 doc/config.sub.1          |  6 ++++--
 testsuite/config-sub.data |  2 ++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/config.sub b/config.sub
index 4aaae46..ad28d43 100755
--- a/config.sub
+++ b/config.sub
@@ -4,7 +4,7 @@
 
 # shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
 
-timestamp='2024-05-27'
+timestamp='2025-03-20'
 
 # 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
@@ -71,6 +71,8 @@ Options:
   -t, --time-stamp   print date of last modification, then exit
   -v, --version      print version number, then exit
 
+Set VERBOSE to see each part labeled
+
 Report bugs and patches to <config-patches@gnu.org>."
 
 version="\
@@ -1554,6 +1556,9 @@ case $os in
 	solaris)
 		os=solaris2
 		;;
+	sol2*)
+		os=`echo "$os" | sed -e 's|sol|solaris|'`
+		;;
 	unixware*)
 		os=sysv4.2uw
 		;;
@@ -2259,10 +2264,15 @@ case $kernel-$os-$obj in
 	--*)
 		# Blank kernel and OS with real machine code file format is always fine.
 		;;
-	*-*-*)
+	*-*-)
 		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
 		exit 1
 		;;
+	*-*-*)
+		# Kernel and/or OS but machine code format is specified
+		echo "Invalid configuration '$1': Machine code format cannot be specified if the OS is." 1>&2
+		exit 1
+		;;
 esac
 
 # Here we handle the case where we know the os, and the CPU type, but not the
@@ -2344,6 +2354,14 @@ case $vendor in
 esac
 
 echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
+if [ ${VERBOSE+x} ] ; then
+	echo "cpu:   " $cpu    >&2
+	echo "vendor:" $vendor >&2
+	echo "kernel:" $kernel >&2
+	echo "os:    " $os     >&2
+	echo "obj:   " $obj    >&2
+fi
+
 exit
 
 # Local variables:
diff --git a/doc/config.sub.1 b/doc/config.sub.1
index 568811a..1cf975b 100644
--- a/doc/config.sub.1
+++ b/doc/config.sub.1
@@ -1,5 +1,5 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.48.5.
-.TH CONFIG.SUB "1" "May 2024" "GNU config.sub (2024-05-27)" "User Commands"
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.49.3.
+.TH CONFIG.SUB "1" "March 2025" "GNU config.sub (2025-03-20)" "User Commands"
 .SH NAME
 config.sub \- validate and canonicalize a configuration triplet
 .SH SYNOPSIS
@@ -17,6 +17,8 @@ print date of last modification, then exit
 .TP
 \fB\-v\fR, \fB\-\-version\fR
 print version number, then exit
+.PP
+Set VERBOSE to see each part labeled
 .SH "REPORTING BUGS"
 Report bugs and patches to <config\-patc...@gnu.org>.
 .SH COPYRIGHT
diff --git a/testsuite/config-sub.data b/testsuite/config-sub.data
index b528544..3e61afb 100644
--- a/testsuite/config-sub.data
+++ b/testsuite/config-sub.data
@@ -1159,3 +1159,5 @@ ymp						ymp-cray-unicos
 z80						z80-unknown-none
 z80-coff					z80-unknown-coff
 z8k						z8k-unknown-none
+sparc-sol2					sparc-sun-solaris2
+sparcv9-sol2.10					sparcv9-sun-solaris2.10
-- 
2.43.0

Reply via email to