Skip to content

Remove use of shell in subprocess call#30

Closed
gnodar01 wants to merge 1 commit intozmkfirmware:mainfrom
gnodar01:fix-config
Closed

Remove use of shell in subprocess call#30
gnodar01 wants to merge 1 commit intozmkfirmware:mainfrom
gnodar01:fix-config

Conversation

@gnodar01
Copy link
Contributor

This fixes it for myself, but there may have been a good reason for using shell=True, so understandable if this simple "fix" isn't suitable.

- Resolves issue zmkfirmware#27
- use of shell=True requires a string, not a list, and also has some
  security considerations: https://docs.python.org/3.10/library/subprocess.html#security-considerations
@joelspadin
Copy link
Collaborator

IIRC, the reason for shell=True was so that you didn't have to specify the full path of the editor, e.g.

zmk config core.editor "code"

Does this work without the full path specified?

@joelspadin
Copy link
Collaborator

On Windows, removing shell=True does not work when the editor command does not use the full path. It calls _winapi.CreateProcess() which does not appear to search PATH for the program, so this results in a FileNotFoundError instead.

Copy link
Collaborator

@joelspadin joelspadin left a comment

Choose a reason for hiding this comment

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

With

zmk config core.editor "code"

running zmk code with this change on Windows results in a FileNotFoundError. With shell=False, this calls _winapi.CreateProcess(), which doesn't search the PATH for the program.

@joelspadin
Copy link
Collaborator

Fixed on all OSes in #49

@joelspadin joelspadin closed this Jan 5, 2026
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.

2 participants