Fix path quoting in get_cli_string - #719
Open
sunlishuo25 wants to merge 2 commits into
Open
sunlishuo25 wants to merge 2 commits into
sunlishuo25 wants to merge 2 commits into
Conversation
sunlishuo25
marked this pull request as ready for review
October 4, 2026 16:22
This branch has not been deployed
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.
get_cli_string(path="/srv/my app/.env", action="get", key="DEBUG")produces a command with an unquoted--fileargument. A POSIX shell splits the path at the space, so the CLI cannot read the intended file. An apostrophe in the directory name also breaks shell parsing.Convert the path to a string before quoting it with
shlex.quote, preserving existingpathlib.Pathsupport. Regression tests pass generated arguments to the actual CLI for both strings andPathobjects, including spaces and an apostrophe. Shell variables and wildcards in filenames are now treated literally; callers wanting shell expansion should expand the path before calling this function. The CLI's existing~expansion still works.Validation on macOS / Python 3.11: 294 pytest tests, 222 POSIX shell CLI calls and 60 Fabric-wrapper simulations pass, along with Ruff lint/format and mypy for Python 3.10–3.14. Regression cases cover strings and
Pathobjects; the space and apostrophe cases fail before the fix. Linux/Windows/PyPy runtimes were not tested locally.Developed with GPT assistance.