Skip to content

Quote PWD to handle repository paths containing spacesPath quote - #331

Open
roybotbot wants to merge 3 commits into
geometry-zsh:mainfrom
roybotbot:path-quote
Open

Quote PWD to handle repository paths containing spacesPath quote#331
roybotbot wants to merge 3 commits into
geometry-zsh:mainfrom
roybotbot:path-quote

Conversation

@roybotbot

Copy link
Copy Markdown

Summary

This PR fixes prompt failures when the current repository is located in a directory whose path contains spaces.

Example:

~/Documents/Brain II

Previously, Geometry could emit an error like:

fatal: /Users/johndoe/Documents/Brain: '/Users/johndoe/Documents/Brain' is outside repository at '/Users/johndoe/Documents/Brain II'

Root cause

Geometry passed $PWD to geometry::wrap() without quoting it in multiple locations. As a result, paths containing spaces were split into multiple shell arguments before cd and Git helper functions executed.

Changes

  • Quote all $PWD arguments passed to geometry::wrap().
  • Change:
builtin cd -q $1

to:

builtin cd -q -- "$1"

to safely handle paths containing spaces and other special characters.

  • Quote the remaining call in functions/geometry_git:
geometry::wrap "$PWD" $git_info

Testing

Tested on macOS using zsh and Oh My Zsh.

Verified that repositories located in directories containing spaces now render correctly without Git errors, while repositories in paths without spaces continue to behave as expected.

Fixes #330

Signed-off-by: Roy Natian <1146050+roybotbot@users.noreply.github.com>
Signed-off-by: Roy Natian <1146050+roybotbot@users.noreply.github.com>
Signed-off-by: Roy Natian <1146050+roybotbot@users.noreply.github.com>
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.

Bug: Geometry prompt fails in Git repositories located in directories with spaces

1 participant