-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Fix 243417: sanitize env command output for bash integration #243673
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
Conversation
src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-bash.sh
Show resolved
Hide resolved
@anthonykim1 could you review+test this one? |
Currently the shellintegration-bash.sh assumes the env output includes only lines of simple key=value pairs. As a result, when an exported function is displayed over multiple lines, such assumption no longer holds. Hence we "sanitize" env output by excluding exported functions.
So that we only need to run the env command once.
- avoid redundunt assosicate array support checks - avoid unbound variable access issues - avoid leaking function local variables - prefer to check array length for emptiness
Hi @ryenus Thanks much for putting up this PR. I have to admit, we did suffer through some pain in the bash shell integration script where we had bunch of debris from user's env show up in the terminal. I did make some changes recently to resolve this and separate the envs with null delimiter here Would you be able to check on the latest vscode-insiders version how this would behave on your setup? I feel like it may still be worth taking the suggestion from |
@anthonykim1, good that you brought this up, please consider these:
With that I'd suggest to NOT include the Meanwhile please also checkout the fixes in minor shell integration code style fix (cc42b1d). While |
Thanks @ryenus |
@anthonykim1, may I ask what would you expect as of now?
|
@ryenus Sounds good, just wanted to make sure I didn't miss anything before I close this out.
May come in handy in the future when we make the env setting configurable as opposed to being the "hardcoded" list right now. I'd /cc you then :) |
In the current bash shell integration implementation, it only considers the lines of simple key/value pairs while processing the output of the env command. However, when there're exported shell functions, which are typically printed over multiple lines, there could be lines with arbitrary shell script that might lead to unexpected result, causing errors like:
Fortunately with
env -0
, it becomes possible to join the lines of an exported function into one line with a custom line separator, such as '\r', or any other unused ascii control characters. With that we could also exclude the exported functions from code completion suggestions:Fixes #243417