Some archives contain folders with spaces in their name.
Sometimes while I'm browsing these folders, I want to open a terminal in current position, so I copy the path to paste it after a cd command.
Of course when there are spaces in the path, cd won't work unless all spaces are escaped.
Since I find it annoying not to be able to paste paths after cd, I just added this function to my .bash_aliases:
function cd {
if [ -z "$*" ]; then
command cd
else
command cd "$*"
fi
}
So mkdir "an awful dir name" && cd an awful dir name now works as expected (what else should cd an awful dir name do?).
Since .bash_aliases shouldn't affect non-interactive shells, other scripts should still work with builtin cd.
Now the question is: can this trick cause problems on my shell? Or am I freaking out for no reason?
two spaces? Withspace and tab? Or with* and &? And given that your function is specific tocd, it's probably less effort in the long run just to put single-quotes around what you're pasting than to try to 'unexpand' the command. (Hmm, Markdown shows those two spaces as one, and the tab as a single space. But I think you can see the problem). \$\endgroup\$-P... That's why I asked : ) \$\endgroup\$