Skip to content

Conversation

@matteius
Copy link
Member

Summary

Fixes #6503

#6462 introduced a regression where pipenv shell fails on ZSH with a parse error:

eval "_pipenv_old_deactivate() { $(declare -f deactivate | tail -n +2) }";
zsh: parse error near `}'

Root Cause

The previous implementation used declare -f inside an eval statement for both bash and zsh. However, zsh handles command substitution differently - it expands $() before parsing the function definition, causing a parse error.

Solution

This fix separates the zsh and bash cases:

  • zsh: Uses functions -c to copy function definitions (same approach as fish)
  • bash: Continues using declare -f which works correctly in bash

Testing

Enhanced the existing unit test to verify zsh uses functions -c (not declare -f) to prevent future regressions.

Test Results

tests/unit/test_core.py::test_deactivate_wrapper_script_includes_unset_pipenv_active PASSED

Pull Request opened by Augment Code with guidance from the PR author

Fixes #6503

The previous implementation used 'declare -f' inside an eval statement for
both bash and zsh. However, zsh handles command substitution differently -
it expands $() before parsing the function definition, causing a parse
error: 'zsh: parse error near }''

This fix separates the zsh and bash cases:
- zsh: Uses 'functions -c' to copy function definitions (same approach as fish)
- bash: Continues using 'declare -f' which works correctly in bash

Also enhanced the test to verify zsh uses 'functions -c' (not 'declare -f')
to prevent future regressions.
@matteius matteius merged commit 6ae09f2 into main Dec 17, 2025
19 of 20 checks passed
@matteius matteius deleted the fix/zsh-shell-parse-error-6503 branch December 17, 2025 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#6462 introduced a bug on ZSH with the pipenv shell subcommand

2 participants