Skip to content

Fix path quoting in get_cli_string - #719

Open
sunlishuo25 wants to merge 2 commits into
theskumar:mainfrom
sunlishuo25:fix/quote-cli-env-path
Open

sunlishuo25 wants to merge 2 commits into
theskumar:mainfrom
sunlishuo25:fix/quote-cli-env-path

Conversation

@sunlishuo25

Copy link
Copy Markdown

get_cli_string(path="/srv/my app/.env", action="get", key="DEBUG") produces a command with an unquoted --file argument. 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 existing pathlib.Path support. Regression tests pass generated arguments to the actual CLI for both strings and Path objects, 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 Path objects; the space and apostrophe cases fail before the fix. Linux/Windows/PyPy runtimes were not tested locally.

Developed with GPT assistance.

@sunlishuo25
sunlishuo25 marked this pull request as ready for review October 4, 2026 16:22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant