Skip to content

Conversation

@padiakalpesh
Copy link

@padiakalpesh padiakalpesh commented Apr 11, 2024

The use of $* prevents correctly cd'ing into a directory with spaces in its path name since each segment of the name around the space is treated as if it is a separate argument.

Example:
"dir/path with spaces" is treated as dir/path and with and spaces. This causes cd to fail. It also causes __gvm_oldcd to fail, although call to builtin cd will succeed.

Same issue happens if path is specified as dir/path\ with\ spaces.

This patch fixes this issue by using "$@" to correctly handle spaces.

Fixes #457

The use of `$*` prevents correctly cd'ing into a directory with spaces in its path name since each segment of the name around the space is treated as if it is a separate argument. 

Example:
`"dir/path with spaces"` is treated as `dir/path` and `with` and `spaces`. This causes `cd` to fail. It also causes `__gvm_oldcd` to fail, although call to `builtin cd` will succeed.

Same issue happens if path is specified as `dir/path\ with\ spaces`. 

This patch fixes this issue by using "$@" to correctly handle spaces.
@mbbush
Copy link

mbbush commented Jun 8, 2024

Thanks for posting a fix!

Speaking as a GVM noob, why does it need to override the built-in cd function anyways? As the presence of this subtle error shows, that seems rather unwise.

djylb added a commit to djylb/gvm that referenced this pull request Sep 15, 2025
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.

Overriden cd fails to switch to paths with spaces

2 participants