-
Notifications
You must be signed in to change notification settings - Fork 298
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
Use current $SHELL for shell-plugin, fix #97 #100
Conversation
Uh, damn! Will I break anything with the PR if I rewrite the history within my fork? |
The PR hasn't been merged yet, so I guess it's okay if you push a new history. Maybe you'll have to close this PR and open a new one, or the UI will notify us the history changed. I'm sure GitHub engineers thought about this use case ;-) Maybe a FAQ describes this case. If you aren't confident about that, just create a dummy repository and do some tests (I'm interested in the answer too actually). I can even create a PR for you ;-) |
Well, it seems it's not recommend:
It can corrupt you PR, but they don't explain in what. Since it would be only changing a comment, and since the original forked |
It's totally fine to force push to your own repo when updating a pull request. |
@@ -41,8 +41,10 @@ def _process_commands(self, data): | |||
self._log.lowinfo(cmd) | |||
else: | |||
self._log.lowinfo('%s [%s]' % (msg, cmd)) | |||
executable = os.environ.get('SHELL') if os.environ.get('SHELL') else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do dict.get(key, default_value)
(so os.environ.get('SHELL', None)
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I'll adjust it soon, thanks. I'll just omit the second argument since it defaults to None
.
Sorry for the delay… this somehow fell off my radar. Merged in 913d548. Thanks for the contribution! |
On POSIX-like systems, calling `subprocess.call()` with both `shell=True` and `executable='...'` has the following behavior: > If `shell=True`, on POSIX the _executable_ argument specifies a > replacement shell for the default `/bin/sh`. (via https://docs.python.org/3/library/subprocess.html?highlight=subprocess#popen-constructor) This seems to have a similar behavior on Windows, but this is problematic when a POSIX shell is substituted for cmd.exe. This is because when `shell=True`, the shell is invoked with a '/c' argument, which is the correct argument for cmd.exe but not for Bash, which expects a '-c' argument instead. See here: https://github.com/python/cpython/blob/1def7754b7a41fe57efafaf5eff24cfa15353444/Lib/subprocess.py#L1407 This is problematic when combined with Dotbot's behavior, where the `executable` argument is set based on `$SHELL`. For example, when running in Git Bash, the `$SHELL` environment variable is set to Bash, so any commands run by Dotbot will fail (because it'll invoke Bash with a '/c' argument). This behavior of setting the `executable` argument based on `$SHELL` was introduced in 7593d8c. This is the desired behavior. See discussion in #97 and #100. Unfortunately, this doesn't work quite right on Windows. This patch works around the issue by avoiding setting the `executable` argument when the platform is Windows, which is tested using `platform.system() == 'Windows'`. This means that shell commands executed by Dotbot on this platform will always be run using cmd.exe. Invocations of single programs or simple commands will probably work just fine in cmd.exe. If Bash-like behavior is desired, the user will have to write their command as `bash -c '...'`. This shouldn't have any implications for backwards-compatibility, because setting the `executable` argument on Windows didn't do the right thing anyways. Previous workarounds that users had should continue to work with the new code. When using Python from CYGWIN, `platform.system()` returns something like 'CYGWIN_NT-...', so it won't be detected with the check, but this is the correct behavior, because CYGWIN Python's `subprocess.call()` has the POSIX-like behavior. This patch also refactors the code to factor out the `subprocess.call()`, which was being called in both `link.py` and `shell.py`, so the workaround can be applied in a single place. See the following issues/pull requests for a discussion of this bug: - #170 - #177 - #219 An issue has also been raised in Python's issue tracker: - https://bugs.python.org/issue40467 Thanks to @shivapoudel for originally reporting the issue, @SuJiKiNen for debugging it and submitting a pull request, and @mohkale for suggesting factoring out the code so that other plugins could use it.
No description provided.