gpt4 book ai didi

shell - test -h 和 test -L 的区别

转载 作者:行者123 更新时间:2023-11-28 19:42:06 25 4
gpt4 key购买 nike

ksh shell 中 test -L filenametest -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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com