ram*_*ion 6 osx symlink homebrew
在我的 OSX 10.9 机器上使用自制软件安装 SWI-Prolog 时,我遇到了一个奇怪的问题。我正在尝试调试它以找出它是谁的错误(SWI-Prolog 的、自制软件的或 OSX 的),所以我可以适当地报告它并修复它。
将swipl在我的道路是/usr/local/bin/swipl其符号链接到/usr/local/Cellar/swi-prolog/6.2.3/bin/swipl
该符号链接/usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl。
% which swipl
/usr/local/bin/swipl
% find /usr/local -name swipl -exec ls -l {} \;
lrwxr-xr-x 1 rampion admin 36 Oct 23 20:54 /usr/local/bin/swipl -> ../Cellar/swi-prolog/6.2.3/bin/swipl
lrwxr-xr-x 1 rampion admin 48 Oct 23 20:54 /usr/local/Cellar/swi-prolog/6.2.3/bin/swipl -> ../lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl
-r-xr-xr-x 1 rampion admin 8760 Oct 23 20:54 /usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl
Run Code Online (Sandbox Code Playgroud)
我可以在/usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl以下位置运行实际的可执行文件:
% /usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.2.3)
...
Run Code Online (Sandbox Code Playgroud)
我可以在/usr/local/Cellar/swi-prolog/6.2.3/bin/swipl以下位置使用符号链接:
% /usr/local/Cellar/swi-prolog/6.2.3/bin/swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.2.3)
...
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用符号链接 at 时/usr/local/bin/swipl,它只是符号链接到另一个符号链接,我收到一个错误:
% /usr/local/bin/swipl
Abort trap: 6
% echo $?
134
Run Code Online (Sandbox Code Playgroud)
我也可以制作我自己的符号链接/usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl,它们可以工作:
% ln -s /usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/bin/x86_64-darwin13.0.0/swipl swipl.0
% ./swipl.0
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.2.3)
...
Run Code Online (Sandbox Code Playgroud)
和我自己的符号链接/usr/local/Cellar/swi-prolog/6.2.3/bin/swipl,它们失败了:
% ln -s /usr/local/Cellar/swi-prolog/6.2.3/bin/swipl swipl.1
% ./swipl.1
Abort trap: 6
% echo $?
134
Run Code Online (Sandbox Code Playgroud)
所以我不知道出了什么问题。为什么指向文件的符号链接有效,但指向文件的符号链接的符号链接失败?
我不认为这与版本有任何关系,也与链接问题无关,可能是正在运行的脚本在通过符号链接调用时无法处理从多个间接级别进行的调用。
假设我有一个像这样的链接到文件的链接的设置。
$ tree
.
|-- 1
| |-- 2
| | |-- 3
| | | |-- 4
| | | | `-- afile
| | | `-- afile -> 4/afile
| | `-- afile -> 3/afile
| `-- afile -> 2/afile
`-- afile -> 1/afile
Run Code Online (Sandbox Code Playgroud)
这样就有了一个单一的文件,1/2/3/4/afile而afile上面的所有都是相互链接的链,最终导致了单一的afile文件。
$ find . -ls
10890091 4 drwxrwxr-x 3 saml saml 4096 Oct 28 22:03 .
10890244 0 lrwxrwxrwx 1 saml saml 7 Oct 28 22:03 ./afile -> 1/afile
10890107 4 drwxrwxr-x 3 saml saml 4096 Oct 28 22:02 ./1
10890247 0 lrwxrwxrwx 1 saml saml 7 Oct 28 22:02 ./1/afile -> 2/afile
10890121 4 drwxrwxr-x 3 saml saml 4096 Oct 28 22:02 ./1/2
10890246 0 lrwxrwxrwx 1 saml saml 7 Oct 28 22:02 ./1/2/afile -> 3/afile
10890136 4 drwxrwxr-x 3 saml saml 4096 Oct 28 22:02 ./1/2/3
10890245 0 lrwxrwxrwx 1 saml saml 7 Oct 28 22:02 ./1/2/3/afile -> 4/afile
10890137 4 drwxrwxr-x 2 saml saml 4096 Oct 28 22:06 ./1/2/3/4
10890243 4 -rw-rw-r-- 1 saml saml 5 Oct 28 22:06 ./1/2/3/4/afile
Run Code Online (Sandbox Code Playgroud)
我始终可以从上面的任何链接访问该文件,例如:
$ pwd
/home/saml/tst/97990/1
$ cat afile
blah
Run Code Online (Sandbox Code Playgroud)
我可以用来readlink找出链接指向的规范路径:
$ readlink -f afile
/home/saml/tst/97990/1/2/3/4/afile
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
523 次 |
| 最近记录: |