Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between test -h and test -L

What is the difference between test -L filename and test -h filename in ksh shell. From the man page, both were used to identify a symbolic link, but I want to know the exact difference.

Here is the description from the man page.

 -h file                 True if file exists and  is  a  sym-
                         bolic link.
 -L file                 True if file exists and  is  a  sym-
                         bolic link.
like image 263
Sachin Chourasiya Avatar asked Jan 04 '10 05:01

Sachin Chourasiya


People also ask

What's the difference between test and testing?

test: countable noun A test is a deliberate action or experiment to find out how well something works. testing: 2. uncountable noun Testing is the activity of testing something or someone in order to find out information.

What is the difference between test?

The Difference between Test and Exam – Meaning Both are basically forms of assessing skills or knowledge or specimens. One can differentiate between these two terms based on the context they are used for. Tests are a much more simplified process, whereas exams are an extensive process that is used to reach a result.

Do you say test or on a test?

In the US it's always on the test. "I hope you do well on the test" is correct. "Try to stay relaxed in the test" is not anything that I've heard. The more common preposition is "during the test" -- although if someone said "in the test" I'd know what they meant.

Do you do a test or make a test?

COMMON ERRORS ► Don't say 'make a test'. Say take a test or do a test.


1 Answers

The source code for ksh93, in file bltins/test.c, shows that these two options are treated exactly the same, except for the author's hopes for the 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));

From this I conclude that they behave exactly the same, but that -h is a legacy option and may one day disappear :-)

like image 157
Norman Ramsey Avatar answered Oct 19 '22 01:10

Norman Ramsey