Hi Guillem,

Guillem Jover wrote:
> > IMHO the man page should explicitly mention that if the parameter to -S
> > starts with a slash, the parameter is taken as complete file name while
> > it is taken as substring match on path and file name otherwise.
> 
> Indeed, this is not clear at all. I'll document it for 1.18.x.

Thanks, appreciated!

> The actual behavior is:
> 
>   If the first character is any of "*[?/" then it will be considered a
>   pattern, and it will be surrounded by *, as in "*string*".

I think there is a "not" missing before "any": If it starts with a
pattern character or the root path, no asterisks for substring
matching should be added.

At least the code has a "!" before the strchr:

    407     if (!strchr("*[?/",*thisarg)) {
    408       varbuf_reset(&vb);
    409       varbuf_add_char(&vb, '*');
    410       varbuf_add_str(&vb, thisarg);
    411       varbuf_add_char(&vb, '*');
    412       varbuf_end_str(&vb);
    413       thisarg= vb.buf;
    414     }

I read this as follows:

strchr returns NULL (false) if there's no match. The "!" negates this,
i.e. it becomes true if there's no match. So the block is executed and
the asterisks are added if there's no such match.

>   If the string contains any of "*[?\\", then it's considered a
>   glob pattern. Otherwise a literal path lookup is performed.

It probably should be mentioned that this check is done after the
potential adding of asterisks around the pattern as mentioned above,
i.e. that those are sequential checks and not either/or. At least
that's how I read the code after line 414 of src/querycmd.c

                Regards, Axel
-- 
 ,''`.  |  Axel Beckert <a...@debian.org>, http://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5
  `-    |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to