Re: [External] : [PATCH] expand: Add bypass for literal "]" in expandmeta

Jan Pechanec <[email protected]> Mon, 10 Mar 2025 09:35:00 +0100
Newsgroups org.kernel.vger.dash
Message-ID <Z86kNH+oXupDQJ0X@len49>
...

> Fix performance regression for idiomatic "[ ... ]" expression by
> adding a bypass for a literal "]" in pathname expansion.
> 
> Reported-by: Jan Pechanec <[email protected]>
> Fixes: 8d0eca2d9fb5 ("expand: Rewrite expmeta meta detection")
> Signed-off-by: Herbert Xu <[email protected]>
> 
> diff --git a/src/expand.c b/src/expand.c
> index 7a30648..5114646 100644
> --- a/src/expand.c
> +++ b/src/expand.c
> @@ -1555,7 +1555,7 @@ expandmeta(struct strlist *str)
>  
>  		if (fflag)
>  			goto nometa;
> -		if (!strpbrk(str->text, "*?]"))
> +		if (!strpbrk(str->text, "*?]") || !memcmp(str->text, "]", 2))
>  			goto nometa;
>  		savelastp = exparg.lastp;

Hi Herbert, thank you, this seems to fix the regression reported.  I
just applied the patch and succesfully re-tested.

Regards,
Jan

-- 
Jan Pechanec <[email protected]>