fix: handle quoted arguments in shell-exec on macOS#1398
Open
LeonidasZhak wants to merge 1 commit into
Open
Conversation
Use shlex::split to properly parse shell-style quoted arguments when spawning commands on macOS. Previously, args were split on whitespace without respecting quotes, causing commands like `shell-exec open -a "Microsoft Outlook"` to fail because the quoted app name was split into separate arguments. Fixes glzr-io#1337
LeonidasZhak
force-pushed
the
codex/fix-shell-exec-quoting-macos
branch
from
June 3, 2026 15:01
477b5fe to
6712c4d
Compare
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.
Summary
Fixes
shell-execon macOS to properly handle quoted arguments (e.g. app names with spaces).Problem
On macOS,
shell-execsplits arguments on whitespace without respecting shell-style quotes. This causes commands like:- "shell-exec open -a \"Microsoft Outlook\""to fail because
"Microsoft Outlook"gets split into"MicrosoftandOutlook"as separate arguments.Solution
Use
shlex::splitto parse the arguments string with proper shell quoting rules before passing them toShell::spawn. Falls back to whitespace splitting ifshlexcan't parse the input (e.g. unmatched quotes).The
shlexcrate is a well-established, pure-Rust implementation of POSIX shell quoting (already a transitive dependency in the lockfile).Changes
packages/wm/Cargo.toml: Addshlex = "1.3"dependencypackages/wm/src/commands/general/shell_exec.rs:split_shell_args()helper (macOS-only, gated with#[cfg(target_os = "macos")])args.split_whitespace()withsplit_shell_args(&args)in the macOSShell::spawncallTesting
cargo check --package wmpassescargo test --package wmpasses (2 existing tests)Related
Fixes #1337