Shell Script thinks directory does not exist when running cd
问题 I have a shell script (which I source into .bashrc) that allows me to jump to my projects directory from anywhere. cdp(){ proj="~/dev/projects/$@/" builtin cd $proj } _my_cdp() { local cur opts cur="${COMP_WORDS[COMP_CWORD]}" opts=$(ls ~/dev/projects/) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) } complete -o nospace -F _my_cdp cdp The problem is, the cd on line 3 says: bash: cd: ~/dev/projects/jsonparse/: No such file or directory Here is the full console output showing the error and