moovweb / gvm

Go Version Manager
http://github.com/moovweb/gvm
MIT License
10.38k stars 546 forks source link

Fix path handling in cd #475

Open padiakalpesh opened 7 months ago

padiakalpesh commented 7 months ago

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

mbbush commented 5 months ago

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.