cd too many arguments on a folder with whitespace

I've tried :

cd 'Program Files'
cd 'Program\ Files'
cd Program\ Files
cd "Program Files"
cd "Program\ Files"

But I still get the error.

Solved it by removing

function cd {
    builtin cd $@
    pwd > ~/.last_dir
}

You should not escape arguments inside " or inside '.

  • 'Program Files' → Good
  • 'Program\ Files' → The \ is kept as is
  • Program\ Files → Good escaping the space
  • "Program Files" → Good
  • "Program\ Files" → The \ is kept as is

Never remove the problem - solve it.

function cd {
    builtin cd "$@"
    pwd > ~/.last_dir
}
4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by