You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The option --riles (rg.files()) does not work because a pattern is always sent to ripgrep. From the ripgrep usage, the --files option must be used without a pattern, and all additional arguments are considered as paths:
rg [OPTIONS] --files [PATH ...]
To Reproduce
>>> from ripgrepy import Ripgrepy
>>> Ripgrepy("", "./ripgrepy/").files().run()
: The system cannot find the path specified. (os error 3)
>>> res = Ripgrepy("", "./ripgrepy/").files().run()
>>> res.command
['rg', '--files', '', './ripgrepy/']
>>> # Running the command `rg --files "" ./ripgrepy/` gives the same error:
>>> import subprocess
>>> subprocess.run(['rg', '--files', '', './ripgrepy/'])
: The system cannot find the path specified. (os error 3)
./ripgrepy/__pycache__\__init__.cpython-38.pyc
./ripgrepy/__init__.py
CompletedProcess(args=['rg', '--files', '', './ripgrepy/'], returncode=2)
Expected behavior
>>> # We should run `rg --files ./ripgrepy/` instead:
>>> subprocess.run(['rg', '--files', './ripgrepy/'])
./ripgrepy/__pycache__\__init__.cpython-38.pyc
./ripgrepy/__init__.py
CompletedProcess(args=['rg', '--files', './ripgrepy/'], returncode=0)
Fix issue securisec#13 and emptying the pattern when using `files()`, and by preventing adding empty the patterns and path to the command.
This also fixes the options `type_list()` and `regexp(pattern)`.
I did it this way because it seems to be what was already expected in the code for type_list() and regexp(pattern).
This PR would prevent creating an object with the arguments to "search for an empty pattern" (i.e. before this change, `Ripgrepy("", ".").run()` valid and equivalent to `rg "" "."`, which is equivalent to `rg --regexp "" "."`.). This basically matches everything, which I guess could be useful (combined with other options) to list the full content of non-ignored searched files in the same format as a pattern-search. But I would doubt that someone currently depends on this "feature" from Ripgrepy... Note thatt it would still be possible to search for this explicitly with `regexp("")`.
Describe the bug
The option --riles (
rg.files()
) does not work because a pattern is always sent to ripgrep. From the ripgrep usage, the --files option must be used without a pattern, and all additional arguments are considered as paths:To Reproduce
Expected behavior
The expected output would be:
Desktop:
rg --files
returns the same "os error 2" on Ubuntu when providing a non-path argument.Additional context
I'll send a PR shortly. I guessed it was better to explain the issue before posting a PR?
The text was updated successfully, but these errors were encountered: