-
Notifications
You must be signed in to change notification settings - Fork 51
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
Having an $EDITOR with arguments raises an exception #11
Comments
@davidparsson I forgot about the old behaviour, but this is most likely ibecause to avoid arbitrary code injection, the library uses subprocess.Popen and passes a list according to the following spec:
the OS then resolves the
EDIT: I was mistaken as I briefly skimmed through the code. Sorry! |
@eugene-eeo, are you saying that this functionality is intended and not likely to change? I'm seeing this on the |
@davidparsson I can't read minds, but probably yes. Relevant code: https://github.com/fmoo/python-editor/blob/master/editor.py#L83 |
All right, if so then that's a shame. Since having a space in an editor is supported by most Unix commands, I think it would make sense to support that here as well. |
I think it can be implemented quite easily using the @davidparsson does this look good? https://gist.github.com/eugene-eeo/f0baa1e79b5efbe240c2d5b3d9a899e8 |
I think I'm a fan of making this use case work. Does this break editors that have a whitespace in their executable name? Not sure that's a use case we need to care about, but I guess we can add some heuristics if we need to support it. My main concern with the PR that I initially looked at was that it changed a couple of other things that seemed unrelated, but I haven't looked too closely yet.
|
shlex handles
|
@eugene-eeo, nearly, but not quite. The |
@davidparsson it should work now :) |
@eugene-eeo, indeed it does. Thanks! Do you think that this will be a part of a future release? |
@davidparsson that will be up to @fmoo. However I don't see any drawbacks from this and it makes the library more Unix-friendly so my best guess would be that it would be part of a future release. |
I published a 1.0.2, but setuptools is throwing a hissy fit and not letting me upload via cli. So I tried uploading via the UI, but pip doesn't seem to see it. Any ideas?
|
Can you share the warning that setuptools displayed? Maybe you've previously published the same version. BTW, my PR that you merged does not include this fix. Let me know if I should include the support for spaces as well, and I'll drop it in and write some tests. |
It was an authentication error. Which is weird because I can use the credentials to login through the web UI.
|
Try checking for extraneous spaces at the end and such. |
I guess we could try to resolve the binary before execution. If it fails, we could fall back to a split/rejoin approach. Thoughts?
|
@fmoo, sorry, I don't think I can be of any help there. @eugene-eeo, would you mind opening a pull request with the fix for this issue as well? |
@fmoo please don't do that because it's IMO really scary magic that you need to maintain in the future. @davidparsson sure, give me a moment. |
I'm still having this issue. Is there anything I can do to help get this fixed and released? |
@davidparsson I think the bugfix is released in the latest version. If not you can try bugging @fmoo to release the current code to PyPI. |
The latest build on pypi is 1.0.3, which is the most recent commit in the
repo. Spaces should no longer raise an exception, but it will treat spaces
like part of the editor filename (e.g., looking for a file named `vim -e`
instead of passing `-e` to vim).
|
I'm still able to reproduce the problem in 1.0.3, and I don't see the fix with The gist in #11 (comment) was never committed/merged. I've opened #15 with those changes. |
Also wow I totally missed the updates to this thread last year. I'll take a look after work today. |
editor.edit('file')
fails when the defined$EDITOR
contains spaces:After removing the space, it works:
Originally (and improperly) reported here as an Alembic issue.
The text was updated successfully, but these errors were encountered: