Skip to content

Avoid shell parsing for Python helper commands - #327

Open
StantonMatt wants to merge 1 commit into
extrabacon:masterfrom
StantonMatt:fix-python-path-spaces
Open

Avoid shell parsing for Python helper commands#327
StantonMatt wants to merge 1 commit into
extrabacon:masterfrom
StantonMatt:fix-python-path-spaces

Conversation

@StantonMatt

Copy link
Copy Markdown

Summary

  • replace shell-string execution in checkSyntaxFile, getVersion, and getVersionSync with argument-vector execFile calls
  • fix paths with spaces for explicit Python executable paths and syntax-checked file paths
  • add regressions for getVersion(), getVersionSync(), and checkSyntaxFile() paths containing spaces

Fixes #181.

Why

The previous implementation built commands like ${pythonPath} --version. That breaks when the Python executable path contains spaces and also leaves these helpers dependent on shell parsing. Passing the executable and arguments separately avoids quoting issues.

Verification

  • npm test -- --grep "path contains spaces|executable path contains spaces"
  • npm test
  • npx prettier --check index.ts test/test-python-shell.ts
  • git diff --check
  • review-fix-loop: clean, no introduced correctness/security/maintainability issues

Signed-off-by: Matthew Stanton <stantonmatthewj@gmail.com>

@PNHD PNHD left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 0208d08 with the shell-execution boundary in mind.

Passing the Python executable and arguments separately through execFile/execFileSync fixes the path-with-spaces bug from #181 and removes shell interpretation from checkSyntaxFile(), getVersion(), and getVersionSync() without changing their observable stdout/stderr contracts.

The focused regressions cover both spaced script paths and spaced executable paths. LGTM.

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.

checkVersion fails when path has space

2 participants