git - zsh波浪号(〜)在OS X上的扩展方式不同

标签 git ssh zsh

不知道是什么原因造成的...

系统:OSX 10.9.2
Shell:在tmux中与oh-my-zsh一起使用zsh

> echo $HOME
/Users/xxmplus
> echo ~
/Users/xxmplus
> echo ~xxmplus
/home/xxmplus

这很烦人,因为我的ssh无法正常工作...
> ssh -T xxmplus@github.com
Could not create directory '/home/xxmplus/.ssh'.
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/xxmplus/.ssh/known_hosts).
Hi xxmplus! You've successfully authenticated, but GitHub does not provide shell access.

有什么建议么?谢谢!

最佳答案

最可能的原因是用户数据库中定义的主目录与您的配置文件和登录脚本设置为$HOME的目录不同。

至于,

> echo $HOME
/Users/xxmplus
> echo ~
/Users/xxmplus

上面严格按照规范,一个独立的~在POSIX中被简单地定义为$ HOME,因此证明很少。

但这是不同的:
> echo ~xxmplus
/home/xxmplus

规格说明如下:

... the tilde-prefix shall be replaced by a pathname of the initial working directory associated with the login name obtained using the getpwnam() ... If the system does not recognize the login name, the results are undefined



http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_01

因此,另一个不太可能的选择是您遇到了规范的未定义行为部分–可能是在包装盒上无法识别登录名(xxmplus)的情况下,特别是无法使用getpwnam()获得登录名,但是更简单的解释是它在那里,您只需要在用户数据库中更改主目录即可。

关于git - zsh波浪号(〜)在OS X上的扩展方式不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22700025/

相关文章:

git - 如何删除冒号后的自动完成文本?

git - 在 Windows 和 WSL 之间共享 git repo 符号链接(symbolic link)

git - 如何使用 Git 进行多任务处理

python - 如何通过删除输出和转换来对 .ipynb 进行版本控制?

linux - 如何在 github 上为 1 个用户的 2 个 repo 添加部署 key

git - 同时显示 git diff 和 git status

bash - 从 zsh 恢复到 bash 后 Vim/Vundle 坏了

linux - awk:选择文本并使用它

intellij-idea - 通过 SSH 的 IntelliJ Cursive REPL

python - 尝试使用 python 脚本获取源时检测到不安全的依赖于完成的目录