Re: use of "build.sh -B BUILDID".... with patch and more questions

"Greg A. Woods" <[email protected]> Thu, 04 Dec 2025 22:37:43 -0800
Newsgroups gmane.os.netbsd.current,gmane.os.netbsd.devel.toolchain
Organization Planix, Inc.
Message-ID <[email protected]>
--pgp-sign-Multipart_Thu_Dec__4_22:30:58_2025-1
Content-Type: text/plain; charset=US-ASCII

At Fri, 05 Dec 2025 08:51:20 +0700, Robert Elz <[email protected]> wrote:
Subject: Re: use of "build.sh -B BUILDID".... with patch and more questions
>
> I haven't really been following this, I'd never heard of BUILDID
> before, but:
>
>   | +	# remove any leading (and trailing) whitespace
>   | +	val=${val##*[[:blank:]]}
>   | +	val=${val%%*[[:blank:]]}
>
> Those don't do what you want, the first would remove everything up
> to, and including, the rightmost blank in the variable's value.

Oops!  Sigh, I had only tested those with ksh, but not even properly
there it seems.

I think though I've settled on just letting the shell do it while
parsing a command line, i.e.:

	var=$(echo $var)

That gets rid of extraneous duplicate whitespace between words too.

In a function taking a varname argument:

trim ()
{
	local _var _val

	if [ $# -ne 1 -o -z "${1}" ] ; then
		echo "Usage: trim varname" >&2
		return 2
	fi

	_var="$1"
	eval _val=\"\${${_var}}\"

	eval ${_var}=\$\(echo \${_val}\)

	unset _var _val
}

--
					Greg A. Woods <[email protected]>

Kelowna, BC     +1 250 762-7675           RoboHack <[email protected]>
Planix, Inc. <[email protected]>     Avoncote Farms <[email protected]>

--pgp-sign-Multipart_Thu_Dec__4_22:30:58_2025-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
Content-Description: OpenPGP Digital Signature

-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQRuK6dmwVAucmRxuh9mfXG3eL/0fwUCaTJ8JAAKCRBmfXG3eL/0
fzB6AJ0TyZy5UUupe/h4FVS3Ag26KMJIOACg4O3rpnk5VWfkyWqJ6H6Vbr15LMQ=
=/AU1
-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Thu_Dec__4_22:30:58_2025-1--