Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behaviour with relative paths #81

Open
limexp opened this issue Aug 23, 2023 · 0 comments
Open

Incorrect behaviour with relative paths #81

limexp opened this issue Aug 23, 2023 · 0 comments

Comments

@limexp
Copy link

limexp commented Aug 23, 2023

There is an error in case of using relative paths: search with caseSensitive: true returns more results then caseSensitive: false.

Here is an example. Consider the following directories:

.
├── dir1
│   └── file1.txt
└── dir2
    └── file2.txt

Run the following program from the dir1:

import 'package:glob/glob.dart';
import 'package:glob/list_local_fs.dart';

void main(List<String> arguments) {
  print('1: ${Glob('**.txt', caseSensitive: null).listSync()}');
  print('2: ${Glob('**.txt', caseSensitive: false).listSync()}');
  print('3: ${Glob('**.txt', caseSensitive: true).listSync()}');

  print('4: ${Glob('../dir2/**.txt', caseSensitive: null).listSync()}');
  print('5: ${Glob('../dir2/**.txt', caseSensitive: false).listSync()}');
  print('6: ${Glob('../dir2/**.txt', caseSensitive: true).listSync()}');

  print('7: ${Glob('..\\dir2\\**.txt', caseSensitive: null).listSync()}');
  print('8: ${Glob('..\\dir2\\**.txt', caseSensitive: false).listSync()}');
  print('9: ${Glob('..\\dir2\\**.txt', caseSensitive: true).listSync()}');
}

Output on Linux:

1: [LocalFile: './file1.txt']
2: [LocalFile: './file1.txt']
3: [LocalFile: './file1.txt']
4: [LocalFile: './../dir2/file2.txt']
5: []
6: [LocalFile: './../dir2/file2.txt']
7: []
8: []
9: []

Output on Windows:

1: [LocalFile: '.\file1.txt']
2: [LocalFile: '.\file1.txt']
3: [LocalFile: '.\file1.txt']
4: []
5: []
6: [LocalFile: '.\..\dir2\file2.txt']
7: []
8: []
9: []

4 is OK, because caseSensitive defaults to false when context is Windows and true otherwise.

The real problem is that more strict condition caseSensitive: true (6) produces more then caseSensitive: false (5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant