Changed workon's env switching to use OR not $?#59
Changed workon's env switching to use OR not $?#59mergify[bot] merged 1 commit intopython-virtualenvwrapper:mainfrom
Conversation
| type deactivate >/dev/null 2>&1 | ||
| if [ $? -eq 0 ] | ||
| then | ||
| ! type deactivate >/dev/null 2>&1 || { |
There was a problem hiding this comment.
Does this { start a sub shell?
There was a problem hiding this comment.
Sorry for the delay, sidetracked, was this determined to be in a subshell?
I'm finding the whole topic of determining if it is/isn't confusing and unclear.
$BASH_SUBSHELL seems to indicate it is not. It's not in parentheses and it's not a pipe, so I don't see any reason why it would be
Do subshells potentially raise a bunch of potential problems?- I'm just curious, tidbits and all.
edit: grammar
There was a problem hiding this comment.
If it's a sub shell, then actions in the braces don't affect the current shell. Running and then unsetting deactivate won't actually do anything.
https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html#Command-Grouping seems to indicate that {} does not create a new subshell.
There was a problem hiding this comment.
Oh okay! I thought it may have been a compatibility issue, some niche situation or even just bad practice.
I've been daily driving this change, so I know it at least fundamentally works (at least in my env)
dhellmann
left a comment
There was a problem hiding this comment.
It looks like the test suite is happy, too.
Thanks for this!
Calling
type deactivateby itself and using it's exit status breaks if caller is watching for any non-zero exit status.In my case, a GitLab CI pipeline with a runner calling
mkvirtualenvas a Shell command.Example pipeline output:
Tested change on: