Fix pipenv shell --quiet to actually suppress output
Summary
Fixes #5954
The --quiet flag and PIPENV_QUIET environment variable now properly suppress all shell activation output.
Problem
When running pipenv shell, users see 3 lines of output:
❯ pipenv shell
Launching subshell in virtual environment...
. /home/user/.local/share/virtualenvs/project-xxxx/bin/activate
❯ . /home/user/.local/share/virtualenvs/project-xxxx/bin/activate
The --quiet flag was documented but didn't fully suppress the output - specifically, it didn't suppress the activation command echo in pexpect-based compat mode.
Solution
-
Pass
quietparameter tofork_compat(): The shell's compat mode now receives the quiet setting. -
Use
setecho(False)in quiet mode: When quiet mode is enabled, the pexpect session disables echo before sending the activation command, then re-enables it after. This prevents the activation command from being displayed. -
Respect
PIPENV_QUIETenvironment variable: The shell command now checksproject.s.is_quiet()in addition to the--quietflag, so users can setPIPENV_QUIET=1globally.
Usage
# Using the --quiet flag
$ pipenv shell --quiet
# Using the environment variable
$ export PIPENV_QUIET=1
$ pipenv shell
Changes
pipenv/shells.py: Addedquietparameter tofork_compat(), usessetecho(False)to suppress activation command outputpipenv/routines/shell.py: Passquiettofork_compat(), also respectPIPENV_QUIETenvironment variable viaproject.s.is_quiet()
Pull Request opened by Augment Code with guidance from the PR author