1. mac上如果有空格的文件夹, 在脚本中进入不了, 如test space文件夹.
vim testcd.sh
cd "test\ space"
pwd
执行./testcd.sh, 报错找不到
./test.sh: line 1: cd: test : No such file or directory
2. 解决方式eval命令. eval会扫描并替换参数, 在引号内的命令也会执行. 官网
eval cd "test\ space"
pwd
就可以正常执行./testcd.sh