Skip to content

fix: export env vars in bash/zsh completion hooks#112

Merged
tmm merged 3 commits intowevm:mainfrom
LeTamanoir:fix/shell-completion-env-vars
Apr 7, 2026
Merged

fix: export env vars in bash/zsh completion hooks#112
tmm merged 3 commits intowevm:mainfrom
LeTamanoir:fix/shell-completion-env-vars

Conversation

@LeTamanoir
Copy link
Copy Markdown
Contributor

Summary

  • The bash and zsh completion registration scripts set COMPLETE and _COMPLETE_INDEX as shell variables inside $(...) subshells, but never export them
  • The CLI binary checks process.env.COMPLETE to enter completion mode - since the vars aren't exported, it never sees them
  • The binary falls through to normal arg parsing, hits the -- separator, and outputs an error that the shell interprets as completion candidates
  • Fish and nushell are unaffected (they use inline prefix syntax like COMPLETE=fish cmd ...)

Reproduction

# This is what the generated zsh hook does internally:
result=$(
    COMPLETE="zsh"
    env | grep COMPLETE  # nothing - not in env
)

# Fix: export makes it visible to child processes
result=$(
    export COMPLETE="zsh"
    env | grep COMPLETE  # COMPLETE=zsh
)

…ion hooks

The bash and zsh registration scripts set COMPLETE and _COMPLETE_INDEX
as shell variables inside $(...) subshells, but never export them.
This means the CLI binary does not see them in process.env, falls
through to normal arg parsing, and errors on the -- separator.

Fish and nushell are unaffected because they use inline prefix
syntax (COMPLETE=fish cmd ...) which always exports to the child.

Signed-off-by: LeTamanoir <martin.saldinger@kiln.fi>
@LeTamanoir LeTamanoir force-pushed the fix/shell-completion-env-vars branch from 923b9ef to 876c780 Compare April 7, 2026 08:00
@LeTamanoir
Copy link
Copy Markdown
Contributor Author

Sorry somehow I opened a PR about this but mistakenly closed it, gonna try to not blow up this one 😁

@tmm tmm merged commit 96dfee4 into wevm:main Apr 7, 2026
2 checks passed
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.

2 participants