fix: escape single quotes in forwarded env values - #535
Open
Dev-next-gen wants to merge 2 commits into
Open
Dev-next-gen wants to merge 2 commits into
Dev-next-gen wants to merge 2 commits into
Conversation
340d9ab wrapped the injected values in single quotes so that spaces survive `source`, but a value that itself contains a single quote still closes the quoting early. The env file then fails to source with "unexpected EOF while looking for matching `''", and the benchmark never runs. The values come from `--profile-folder` and the user's PATH, so a profile folder like "/tmp/it's here" is enough to break walltime and memory runs. Escape embedded quotes as '\'' so the value is passed through verbatim.
|
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I was reading the history of
run_with_env.rsand noticed that 340d9ab fixed values with spaces by wrapping them in single quotes (export {k}='{v}'), but nothing escapes a single quote inside the value. Such a value closes the quoting early, the env file no longer sources, and the benchmark never starts.The values written there include the
--profile-folderpath and the user'sPATH, so this is reachable from the CLI. On current main (37eba9e), on Linux:With this branch the same command runs the benchmark and exits 0.
The fix escapes embedded quotes as
'\'', so values without a quote produce exactly the same line as before. The memory executor goes through the samecreate_env_fileviaprefix_command_with_env, so it gets the fix too. I only ran the walltime path end to end.I added a unit test that writes an env file with a quoted value, sources it with bash and checks the value comes back unchanged. It fails on main with the error above and passes with the change.
cargo fmt --checkis clean and clippy reports nothing in this file.AI tools used