$HOME 和'~'(波浪号)之间的区别? [英] Difference between $HOME and '~' (tilde)?
问题描述
我一直以为$HOME
和~
是一模一样的,所以可以可以互换使用.今天,当我尝试安装 pylibmc 时,一个 python绑定到 memcached,在我的共享服务器上使用 ~
给了我错误但没有$HOME
.我想说明原因.
libmemcached 是 pylibmc 的要求.我已经安装了 libmemcached在我的主目录下,因为我在服务器上没有根.结果,到安装 pylibmc,我需要确保安装脚本知道在哪里找到 libmemcached.
执行python setup.py install --with-libmemcached=~
时,安装脚本运行
这给出了 libmemcached 找不到的错误.
如果我更改为 --with-libmemcached=$HOME
,则脚本运行
没有任何问题.看起来问题是波浪号没有得到解决.但为什么呢?
shell 将 ~
替换为用户的主目录(update: 或者可能是其他用户,如果 ~
后跟 /
以外的其他内容),但前提是它是单词的第一个字符.
--with-libmemcached=~
的 ~
不在开头,因此 shell 不理会它.
I had always thought that $HOME
and ~
were exactly the same and thus could
be used interchangeably. Today, when I tried to install pylibmc, a python
binding to memcached, on my shared server the use of ~
gave me error but not
$HOME
. I would like to reason out why.
libmemcached is a requirement for pylibmc. I have libmemcached installed under my home directory because I have no root on the server. As a result, to install pylibmc, I need to make sure the installation script knows where to find libmemcached.
When executing python setup.py install --with-libmemcached=~
, the installation
script runs
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_ZLIB -I~/include -I/usr/local/include/python2.7 -c _pylibmcmodule.c -o build/temp.linux-i686-2.7/_pylibmcmodule.o -fno-strict-aliasing
which gives the errors that libmemcached can't be found.
If I change to --with-libmemcached=$HOME
, the script runs
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_ZLIB -I/home/waterbotte/include -I/usr/local/include/python2.7 -c _pylibmcmodule.c -o build/temp.linux-i686-2.7/_pylibmcmodule.o -fno-strict-aliasing
without any problem. It looks like the problem is that tilde doesn't get resolved. But why?
The shell replaces ~
with the user's home directory (update: or perhaps by the home directory of some other user, if ~
is followed by something other than a /
), but only if it's the first character of a word.
--with-libmemcached=~
has ~
not in the beginning, so the shell leaves it alone.
这篇关于$HOME 和'~'(波浪号)之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!