Re: [PATCH 5/5] new: only allow documented test group names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 31, 2021 at 05:12:57PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@xxxxxxxxxx>
> 
> Now that we require all group names to be listed in doc/group-names.txt,
> we can use that (instead of running mkgroupfile) to check if the group
> name(s) supplied by the user actually exist.  This has the secondary
> effect of being a second nudge towards keeping the description of groups
> up to date.
> 
> Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
> ---
>  new |   24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> 
> diff --git a/new b/new
> index 2097a883..44777bd6 100755
> --- a/new
> +++ b/new
> @@ -83,6 +83,14 @@ then
>      exit 1
>  fi
>  
> +# Extract group names from the documentation.
> +group_names() {
> +	grep '^[[:lower:][:digit:]_]' doc/group-names.txt | awk '
> +{if ($1 != "" && $1 != "Group" && $2 != "Name:" && $1 != "all")
> +	printf("%s\n", $1);
> +}'
> +}

Took me a while to realise this was running an awk script for output
slection but using grep for regex based line selection. Awk can do
both of these things just fine, and the result is much more
readable:

group_names() {
	awk '/^[[:lower:][:digit:]_]/ {
		if ($1 != "Group" && $2 != "Name:" && $1 != "all")
			printf("%s\n", $1);
	}' doc/group-names.txt
}


$ awk '/^[[:lower:][:digit:]_]/ { if ($1 != "Group" && $2 != "Name:" && $1 != "all") printf("%s\n", $1); }' t.t
auto
quick
deprecated
acl
admin
aio
atime
....

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux