Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
Re: keydisk in installer fix
To:
Andrew Hewus Fresh <andrew@afresh1.com>, tech@openbsd.org
Cc:
krw@openbsd.org
Date:
Sun, 07 Dec 2025 00:19:42 +0000

Download raw body.

Thread
07.12.2025 03:06, Andrew Hewus Fresh пишет:
> It seems somehow a basic regular expression was added in r1.1279 with
> sed -E to enable extended regular expressions.  It seems to work either
> without the E or without the slashes.  Any preference on how to fix it?
> 
> Removing two slashes is one character shorter than removing the E :-)
> 
> OK for either option?
> 
> 
> Index: install.sub
> ===================================================================
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> diff -u -p -r1.1281 install.sub
> --- install.sub	16 Nov 2025 13:15:31 -0000	1.1281
> +++ install.sub	7 Dec 2025 00:00:06 -0000
> @@ -3122,7 +3122,7 @@ pick_keydisk() {
>  	_disk=$resp
>  
>  	make_dev $_disk
> -	_parts=$(disklabel $_disk | sed -En "/.*RAID.*/s/^  \(.\): .*/\1/p")
> +	_parts=$(disklabel $_disk | sed -n "/.*RAID.*/s/^  \(.\): .*/\1/p")
>  	if [[ -n $_parts ]]; then
>  		echo "$_disk must contain a RAID partition."
>  		return 1
> 
> 
> Index: install.sub
> ===================================================================
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> diff -u -p -r1.1281 install.sub
> --- install.sub	16 Nov 2025 13:15:31 -0000	1.1281
> +++ install.sub	6 Dec 2025 23:58:40 -0000
> @@ -3122,7 +3122,7 @@ pick_keydisk() {
>  	_disk=$resp
>  
>  	make_dev $_disk
> -	_parts=$(disklabel $_disk | sed -En "/.*RAID.*/s/^  \(.\): .*/\1/p")
> +	_parts=$(disklabel $_disk | sed -En "/.*RAID.*/s/^  (.): .*/\1/p")

I'd argue less backslash escaping read better.

This can use [$PARTITIONS] instead of . to use logic introduced in that
commit and read a bit clearer, imho.

If you want to trim some more, I guess /RAID/ is enough as s/.../\1/
does all the heavy lifting.

	$ PARTITIONS=a-p
	# disklabel sd0 | sed -En "/RAID/s/^  ([$PARTITIONS]): .*/\1/p"
	a

Either way, OK kn

>  	if [[ -n $_parts ]]; then
>  		echo "$_disk must contain a RAID partition."
>  		return 1
>