即使路径

时间:2018-07-19 11:27:49

标签: android zsh

请帮助。即使adb命令存在于路径中,也找不到该命令。它曾经可以工作,但现在突然停止工作。下面是终端输出。

➜  ~ echo $PATH               
    /usr/local/opt/node@8/bin:/Applications/Postgres.app/Contents/Versions/10/bin:/Users/lance/pear/bin:/usr/local/opt/node@8/bin:/Applications/Postgres.app/Contents/Versions/10/bin:/Users/lance/pear/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.composer/vendor/bin:~/Library/Android/sdk/platform-tools:~/Library/Android/sdk/emulator:~/.composer/vendor/bin:~/Library/Android/sdk/platform-tools:~/Library/Android/sdk/tools:~/Library/Android/sdk/emulator

➜  ~ cd ~/Library/Android/sdk/platform-tools

➜  platform-tools ls
NOTICE.txt        dmtracedump       fastboot          make_f2fs         package.xml       sqlite3
adb               e2fsdroid         hprof-conv        mke2fs            sload_f2fs        systrace
api               etc1tool          lib               mke2fs.conf       source.properties

➜  platform-tools ~

➜  ~ adb devices
zsh: command not found: adb

➜  ~ 

1 个答案:

答案 0 :(得分:2)

zsh(与bash不同)不能代替~检查PATH。它还不会在任何引号(包括双引号)内扩展~

因此,当添加到PATH时,您必须

  • 在未加引号的字符串中使用~
  • 使用不带~(带有任何必要的引号)的完整路径,
  • 使用$HOME代替~(用双引号或未引起双引号)或

例如:

PATH=$PATH:~/Library/Android/sdk/platform-tools
PATH=$PATH:/Users/lance/Library/Android/sdk/platform-tools
PATH=$PATH:'/Users/lance/Library/Android/sdk/platform-tools'
PATH=$PATH:$HOME/Library/Android/sdk/platform-tools
PATH="$PATH:$HOME/Library/Android/sdk/platform-tools"