Subject: Re: bug#59639: Is this a bug?

From: Gary Johnson <[email-masked]>
Date: Sun, 27 Nov 2022 10:54:07 -0800

On 2022-11-27, Klaus Dittrich wrote:
> Given file.txt with three lines:
> 
> /usr/local/lib/gdk-pixbuf-2.0
> empty
> /usr/local/lib/libgd2
> 
> When I do:
> 
> grep gdk file.txt
> this results in : /usr/local/lib/gdk-pixbuf-2.0
> 
> Which looks ok for me.
> 
> When I do:
> 
> grep  gdk* file.txt
> this results in : /usr/local/lib/gdk-pixbuf-2
>                   /usr/local/lib/libgd2.0
> 
> This looks like then '*' eats the 'k'
> from 'gdk*' and looks for 'gd'' instead of 'gdk*'.
> Or equivalent to grep  gd* file.txt
> Or equivalent to grep  gd file.txt
> 
> grep   gdk.* file.txt
> this results in : /usr/local/lib/gdk-pixbuf-2.0
> 
> Which looks ok for me.
> Either now the point is eaten or the point is correctly replaced by
> 'any character'

> Can you please verify if this is a bug or anything in my thinking is
> wrong beacuse I have overlooked something?

I think you are confusing regular expressions with globs.

The pattern used by most if not all shells for file-name expansion
is a glob.  In a glob, an asterisk is replaced by zero or more
characters.  In a glob, gdk* means gdk followed by zero or more
characters.

The pattern argument to grep is a regular expression.  In a regular
expression, an asterisk means zero or more of the preceding element,
which in the simplest case is a single character.  In a regular
expression, gdk* means gd followed by zero or more of the letter k.

HTH,
Gary