ksh shell 中 test -L filename
和 test -h filename
有什么区别。从手册页来看,两者都用于标识符号链接(symbolic link),但我想知道确切的区别。
这是手册页中的描述。
-h file True if file exists and is a sym-
bolic link.
-L file True if file exists and is a sym-
bolic link.
最佳答案
ksh93
的源代码,在文件 bltins/test.c
中,表明这两个选项的处理方式完全相同,除了作者对 future 的希望:
case 'L':
case 'h': /* undocumented, and hopefully will disappear */
if(*arg==0 || arg[strlen(arg)-1]=='/' || lstat(arg,&statb)<0)
return(0);
return(S_ISLNK(statb.st_mode));
由此我得出结论,它们的行为完全相同,但是 -h
是一个遗留选项,可能有一天会消失:-)
关于shell - test -h 和 test -L 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1997666/