Bug Description
The cd() override in scripts/env/cd fails when changing into directories that contain spaces in their path. The shell reports cd: too many arguments.
Root Cause
There are two locations where $* is used unquoted, causing word splitting on paths with spaces:
Line 23 - Definition of __gvm_oldcd:
eval "$(echo "__gvm_oldcd() { builtin cd \$*; return \$?; }")"
Line 49 - Invocation inside cd():
Steps to Reproduce
mkdir -p "/tmp/test dir with spaces"
cd "/tmp/test dir with spaces"
# Error: cd: too many arguments
Expected Behavior
cd "/tmp/test dir with spaces" should change into the directory successfully.
Proposed Fix
Replace the unquoted $* with quoted "$@" in both locations:
Line 23:
eval "$(echo "__gvm_oldcd() { builtin cd \"\$@\"; return \$?; }")"
Line 49:
Environment
- GVM version: 1.0.22
- OS: Linux (Ubuntu)
- Shell: Bash
Bug Description
The
cd()override inscripts/env/cdfails when changing into directories that contain spaces in their path. The shell reportscd: too many arguments.Root Cause
There are two locations where
$*is used unquoted, causing word splitting on paths with spaces:Line 23 - Definition of
__gvm_oldcd:Line 49 - Invocation inside
cd():__gvm_oldcd $*Steps to Reproduce
Expected Behavior
cd "/tmp/test dir with spaces"should change into the directory successfully.Proposed Fix
Replace the unquoted
$*with quoted"$@"in both locations:Line 23:
Line 49:
__gvm_oldcd "$@"Environment