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

"Greg A. Woods" <[email protected]>
Newsgroups gmane.os.netbsd.current,gmane.os.netbsd.devel.toolchain
Organization Planix, Inc.
Message-ID <[email protected]>
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]>
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQRuK6dmwVAucmRxuh9mfXG3eL/0fwUCaTJ8JAAKCRBmfXG3eL/0
fzB6AJ0TyZy5UUupe/h4FVS3Ag26KMJIOACg4O3rpnk5VWfkyWqJ6H6Vbr15LMQ=
=/AU1
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.