Cursor as git editor failing to handle paths with spaces

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

My git editor is set to cursor with the following code in “~/.gitconfig”

[core]
    editor = cursor --wait

PROBLEM:
I have a git repo in a folder that has spaces in its path.
If I run git commit in that git repo, cursor cli interprets each chunk of the “.git/COMMIT_EDITMSG” path, split at the spaces, as a separate path, and opens/creates each separately. The correct “.git/COMMIT_EDITMSG” is never opened and thus git commit aborts due to an empty commit message.

DIAGNOSIS:
with the help of sonnet 4.5 I identified the problem as line 20 of “/usr/local/bin/cursor” (linked from “/Applications/Cursor.app/Contents/Resources/app/bin/code”) which is eval "$CURSOR_CLI" "$@"
In the words of sonnet 4.5: “Excellent! The arguments ARE being received correctly - the path with spaces is a single argument (Arg[2]).
The problem is on line 20 with eval “$CURSOR_CLI” “$@”. When eval executes, it re-parses the command string, and “$@” gets expanded without proper quoting for the eval context, causing the path to be split on spaces.
The fix is to properly shell-escape each argument before passing to eval
Sonnet 4.5 proposes this fix:
“Now the function uses printf ‘%q’ to shell-escape each argument before passing it to eval. This ensures that paths with spaces (and any other special characters) are properly quoted. printf ‘%q’ properly escapes each argument for shell evaluation
The escaped arguments are concatenated and passed to eval”

		# Properly escape each argument for eval
		local escaped_args=""
		for arg in "$@"; do
			escaped_args="$escaped_args $(printf '%q' "$arg")"
		done
		echo "[DEBUG] Escaped command: $CURSOR_CLI$escaped_args" >&2
		eval "$CURSOR_CLI$escaped_args"

Steps to Reproduce

create a folder with a space in it
git init
echo ‘hi’ > new_file.txt
git commit -a

Expected Behavior

I expect cursor to open the correct “.git/COMMIT_EDITMSG” file (with spaces in its absolute path)

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.44
VSCode Version: 1.99.3
Commit: 9d178a4■■■89981b62546448bb32920a8219a5d0
Date: 2025-10-10T15:43:37.500Z (1 day ago)
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Darwin arm64 23.2.0

MacOs sonoma

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, thanks for the detailed report and diagnosis, super helpful.

You’ve pointed out a clear issue in the Cursor CLI’s argument handling. Using eval causes arguments with spaces to be re‑parsed incorrectly, and your proposed solution with proper escaping (e.g., printf ‘%q’) looks solid.

I’ll pass this to the developers.

1 Like

Glad I found this, I’ve been experiencing the same issue and I haven’t found anything related to this elsewhere online

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.