Re: no match should be no string ?

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

 



On 28/11/2021 16:36, Marc Chantreux wrote:
* the ambiguity when $# is 1: there is no way to know if i have no match
   or if a very bad person named its file \*no_way_this_glob_matches\*.

Agreed that that is annoying.

If your pattern includes literal characters, there is a complicated workaround that you can apply directly in the pattern: use the pattern

  *[n]o_way_this_glob_matches*

If you get back exactly '*[n]o_way_this_glob_matches*', that is because the glob did not match anything. A file by that name would not be picked up by the glob. If you get back anything else, it was found by the glob.

Otherwise, you would need to 'test -e' to double-check.

Cheers,
Harald van Dijk



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux