Skip to content

Parentheses are not treated as literal characters #171

Description

@sapphi-red

For the following script,

import picomatch from 'picomatch';

console.log('# glob="/foo/(a)", target="/foo/a"');
console.log(
  'without extglob (expected: false)',
  picomatch('/foo/(a)', { noextglob: true })('/foo/a')
);
console.log(
  'with extglob (expected: false)',
  picomatch('/foo/(a)', { noextglob: false })('/foo/a')
);
console.log();

console.log('# glob="/foo/(a)?", target="/foo/a"');
console.log(
  'without extglob (expected: false)',
  picomatch('/foo/(a)?', { noextglob: true })('/foo/a')
);
console.log(
  'with extglob (expected: false)',
  picomatch('/foo/(a)?', { noextglob: false })('/foo/a')
);
console.log();

I get the following output:

# glob="/foo/(a)", target="/foo/a"
without extglob (expected: false) true
with extglob (expected: false) true

# glob="/foo/(a)?", target="/foo/a"
without extglob (expected: false) true
with extglob (expected: false) true

All returns true but I think they should return false because ( and ) doesn't have a special meaning (without prefixes like ? for extglobs).
(stackblitz)

I also tested with bash 5.2.21 and it had the behavior I expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions