Quote:
Originally Posted by
Straitsfan
I mean a directory with just that more than one word in its name -- say, for example my\ documents/ as opposed to just documents/
It's not more than one word if you quote it. In that case, there is no field splitting done and it will always be one word (word in the bash man page sense) which happens to contain a space.
Quote:
Originally Posted by
hergp
In this special case there is no effective difference between "$*" and "$@", because in bash the cd builtin accepts only one argument, the name of the directory you want to change to.
That is absolutely incorrect. If there are multiple arguments passed to a script or function, the double-quoted values "$*" and "$@" will ALWAYS differ. The former will always expand to one string, the latter to multiple strings.
If this function were called with two arguments, for example, it would try to cd into a directory named "$1" (as you pointed out, bash's built-in cd would ignore $2 and any other arguments). However, if the code were using "$*" instead, the bash builtin would be passed a single argument whose value would be "$1 $2". Definitely, not the same.
In this case, what is equivalent is the use "$@" and "$1", since bash's cd will ignore all other arguments.
Regards,
Alister