-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Auto-globbing in cmd tasks makes it impossible to pass anything that looks like a glob to the called command #16
Comments
Thanks for the feedback. The existing behaviour does seem problematic. The auto globbing was a very early feature from when I was still trying to avoid having something like shell tasks and I guess it wasn't that well thought through. Looking at it now it seems a better way to achieve what I wanted would be just to set I should look into this some more. Or maybe make the globbing behaviour opt in as you suggest, though I think there's value in not having to use "shell" tasks for most things due to the complexity that introduces à la #15 . |
I kind of expected, similar e.g., to Dockerfile I'm not keen on The current Supporting a shell binary override for That would probably also be a good opportunity to get rid of the It might be better to check if we are running under bash, and then try /usr/bin/bash, and then /usr/bin/sh, and then /bin/sh, and then give up. It's only very recently on recent Windows 10 where you could run Windows-native 'python.exe' under bash from recent gitforwindows or MSYS2, and get the right results; WSL would be right-out, and it's the most-likely Particularly for me, the main use-case I have for poethepoet is to replace the various .bat and .sh scripts that have grown up to wrap the various python invocations my team uses, with platform-agnostic versions, ideally stored in pyproject.toml with the rest of the project definition. |
After taking some time to analyse the problem I think you're right that it doesn't make sense to mess with args passed from the user's shell, and in general quoting an arg should disable glob expansion for that arg. I'll fix it accordingly, which I hope will address your pain point. |
Also disable globbing for quoted command tokens within a cmd task definition to bring behavoir closer to what would be expected, and make it possible to pass strings with glob chars as arguments Resolves #16 In retrospect the extra interpretation of args passed from the command line never really made sense becuase the host shell should handle this.
This change fixes an issue whereby quoted tokens in cmds were passed to the executable without stripping the quotes. Related to #16
I'm having an issue with the following in my pyproject.toml
This works fine:
However, this fails:
Specifically,
"py_unit*.py"
has disappeared. This argument is a glob-pattern to be passed as-is to Pytest, so should not be expanded. The bash-like behaviour of "use glob as-is if not matched" would be less-surprising, producingThe behaviour of course is closer-to-expected if I happen to be in 'tests'
i.e. when I first set this up, it appeared to be working, but only because I happen to have just one test file matching the glob here. It also will then fail to match any subdirectory-held test files that aren't also named test_unit_all_the_tests.py.
In bash,
'py_unit*.py'
would mean "Don't expand this", but there's no way to communicate that to poethepoet as the quotes are already gone before it gets the argument.has the same problem, except it's always globbed from the top-level, not from the directory I happen to be in, leading to:
where the same glob has expanded two different ways.
I'm not sure the 'auto-glob' behaviour makes sense, as there's literally no way for me to express "This is a glob, that isn't" through a cmd task, as it unconditionally tries to expand globs.
It's also a somewhat surprising behaviour, since if I wanted that, I'd use the
shell
runner, or e.g., a pwsh runner per #15, and let it do the globbing.I don't see a particular justification (or documentation) for the "auto-glob" behaviour, so personally I would suggest removing it from cmd.py, along with the vestigates in shell.py. That would mean the
rm -rf
example in the Command Tasks list moves to shell, where it belongs, and is rewritten to use a bash glob, instead of a Python glob, i.e. there's no**
in bash.If it's preferred to be kept, then having a way for the task to specify "No, do not auto-glob my commands" would be handy. I'd just use that all the time, so that
poetry run poe X Y Z
is literallypoetry run <definition of X> Y Z
as I would expect.As another argument towards dropping auto-globbing, I've just realised this would make
grep
orsls
nigh-unusable here, as a regexp on the command line will always be globbed-and-deleted, unless you're very unlucky and it globs into an existing filename, which would not have matched the regexp.The text was updated successfully, but these errors were encountered: