Support pwsh format for show-env export #411
Open
+101
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR demonstrates a solution for #395, with a slightly different strategy that what was discussed.
The issues outlined there:
CARGO_ENCODED_RUSTFLAGS
take non-printable characters that unix shells will accept but pwsh won't.Additionally, the shell escape crate used is escaping for cmd, not pwsh and wouldn't be compatible.
Pwsh does accept embedded unicode codes in strings though. If we encode the values this way, we don't need to worry about printable vs non-printable characters nor any of the specifics for what kinds of characters need to be escaped for what kinds of strings. This is a one-time, very fast operation. Once the emitted string is executed all the escapes are gone.
This approach wouldn't be good for a general-purpose escape function, but it's perfectly suitable for this use case.
The change enables users to execute a pwsh version of the source demo:
Primary goal was to confirm this approach worked. If this is of interest, I can make any changes to the code organization, arg name, etc. The current organization is just what came to mind as I played around with the repo.
Manual test context with binary data in env:
Intermediate state example:
Final result: