glob_match() does not support double-star (**) recursive glob patterns #67

Closed
opened 2026-07-20 17:14:08 +02:00 by TapTap · 0 comments
Owner

Description

The glob_match() function in src/shared/utils.c supports basic wildcard patterns (* matches within a single path component, ? matches a single character), but does NOT support ** (double-star) for recursive directory matching. rsync and most modern file sync tools support ** for matching across directory boundaries.

For example, the pattern src/**/*.c should match src/main.c, src/sub/file.c, src/a/b/c/file.c, etc., but glob_match() currently treats ** the same as * because it processes each * character individually.

Location

src/shared/utils.c:59-82

Suggested Fix

Add support for ** by detecting two consecutive * characters and treating them as a recursive wildcard that matches across / boundaries:

if (*pattern == '*' && *(pattern+1) == '*') {
    // Treat ** as matching across directories
    // Skip any trailing /
    while (*pattern == '*' || *pattern == '/')
        pattern++;
    // Try matching at every position in str
    while (*str) {
        if (glob_match(pattern, str))
            return true;
        str++;
    }
    return glob_match(pattern, str);
}

Severity

Low

Category

Enhancement

## Description The `glob_match()` function in `src/shared/utils.c` supports basic wildcard patterns (`*` matches within a single path component, `?` matches a single character), but does NOT support `**` (double-star) for recursive directory matching. rsync and most modern file sync tools support `**` for matching across directory boundaries. For example, the pattern `src/**/*.c` should match `src/main.c`, `src/sub/file.c`, `src/a/b/c/file.c`, etc., but `glob_match()` currently treats `**` the same as `*` because it processes each `*` character individually. ## Location `src/shared/utils.c:59-82` ## Suggested Fix Add support for `**` by detecting two consecutive `*` characters and treating them as a recursive wildcard that matches across `/` boundaries: ```c if (*pattern == '*' && *(pattern+1) == '*') { // Treat ** as matching across directories // Skip any trailing / while (*pattern == '*' || *pattern == '/') pattern++; // Try matching at every position in str while (*str) { if (glob_match(pattern, str)) return true; str++; } return glob_match(pattern, str); } ``` ## Severity Low ## Category Enhancement
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#67