cacciatc
cacciatc

Reputation: 9

What does 0##*/ do in ZSH?

I understand it is a pattern and it causes some searching to happen:

zsh: no matches found: 0##*/

However, I have no idea what it is searching against or what command line tool is actually fielding the request.

Upvotes: 0

Views: 167

Answers (1)

qqx
qqx

Reputation: 19475

That error comes from zsh itself doing filename expansion (AKA globbing). This is covered in the filename generation section of the zshexpn man page.

If you have the EXTENDED_GLOB option set (covered in the zshoptions man page) the ## token behaves like a + would in an extended regular expression, matching 1 or more occurrences of the preceding item (0 in your example). The following * would match any sequence of characters (including nothing). The / at the end would limit the matches to directories. So the entire pattern would match any directory in your current directory where the name begins with 0. Although there isn't really any reason to use the ## portion; it wouldn't affect the results and makes the pattern more confusing and non-portable to other shells.

If that option isn't set the ## characters would be taken literally. The * and / characters would be treated the same as I described in the preceding paragraph. The entire pattern would match any directory in your current directory where the name begins with 0##.

Upvotes: 1

Related Questions