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
pyvenv activate script failure with specific bash option #69538
Comments
When writing bash shellscripts, I always set options "set -ueC" for strict error checking. However, loading pyvenv's activate and deactivate scripts from bash with "-u" option, they are failure because they may refer undefined shell variables. I hope activate script and deactivate function are enclosed like following block _OLD_BASH_OPTIONS="$-" ### script body ## set -$_OLD_BASH_OPTIONS Another option, all shell-variables in the script change like |
Can you try the attached script in place of the current activate script and see if it meets the requirements? |
This is a perfectly valid bug and I am surprised it was ignored for so long. I just raised a PR for addressing it, please review it. |
Note that in the equivalent issue raised against virtualenv, the concern was raised that some old sh-like shells might not support this syntax, but it was pointed out that it is part of the posix standard. I'm not arguing for or against here, just noting relevant information :) The script comment specifically says "from bash", but presumably the script can be and is sourced from other sh-like shells. |
Based on my tests this worked with all shells I tested with, the syntax being a very old one and not some new/modern one. Passed: bash, zsh, dash, ksh Failed with: tcsh but with the note that even the original code would fail with tcsh anyway. tcsh/csh are not bourne/posix compatible so there is no regression introduced by the the use of "${VAR:-}" syntax. A simple way to test the syntax with enable shell is: |
The bug has been fixed in Python 3.6 and 3.7 (master), thank you Sorin Sbarnea! Python 3.4 and 3.5 don't accept bug fixes anymore, only security fixes: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: