Skip to content

add -n to parameter expansion zsh #252227

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

Merged
merged 2 commits into from
Jun 24, 2025
Merged

add -n to parameter expansion zsh #252227

merged 2 commits into from
Jun 24, 2025

Conversation

anthonykim1
Copy link
Contributor

@anthonykim1 anthonykim1 commented Jun 23, 2025

Resolves: #248463 (comment)

@anthonykim1 anthonykim1 self-assigned this Jun 23, 2025
@anthonykim1 anthonykim1 added bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh, including shell integration labels Jun 23, 2025
@anthonykim1 anthonykim1 requested review from Tyriar and meganrogge June 23, 2025 20:11
@anthonykim1 anthonykim1 marked this pull request as ready for review June 23, 2025 20:12
@anthonykim1
Copy link
Contributor Author

anthonykim1 commented Jun 23, 2025

Could @Tyriar @meganrogge give this a try?
Seems to work on my end.

Relevant setting: terminal.integrated.shellIntegration.environmentReporting

Also do we not show the path to shell integration script on terminal tab hover anymore?
Screenshot 2025-06-23 at 1 04 04 PM

@meganrogge
Copy link
Contributor

Hi Anthony, thanks for working on this. Can you pls explain what your changes do?

@anthonykim1
Copy link
Contributor Author

Yeap! @meganrogge
So we added the parameter expansion approach to avoid using -v since it was invalid command for people's zsh.
But even [[ ${(P)var+_} ]]; did not seem enough for person using zsh 5.0.2.

Adding -n makes it more robust and more compatible. Essentially with -n "${(P)key:-}" we check if the value is non-empty.
We are checking if both key, and non-empty value are present when parsing through env variables we want to send as shell env api.

Tyriar
Tyriar previously requested changes Jun 24, 2025
@anthonykim1 anthonykim1 marked this pull request as draft June 24, 2025 16:19
@anthonykim1 anthonykim1 marked this pull request as ready for review June 24, 2025 16:28
@anthonykim1 anthonykim1 requested a review from Tyriar June 24, 2025 16:28
@anthonykim1 anthonykim1 merged commit 86cfd1b into main Jun 24, 2025
8 checks passed
@anthonykim1 anthonykim1 deleted the anthonykim1/zshAdd-n branch June 24, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh, including shell integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

__vsc_update_env:7: unknown condition: -v
3 participants