bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Documentation] -d returns true for symlink to directory


From: Greg Wooledge
Subject: Re: [Documentation] -d returns true for symlink to directory
Date: Thu, 21 Jul 2016 17:58:23 -0400
User-agent: Mutt/1.4.2.3i

On Thu, Jul 21, 2016 at 03:38:40PM -0600, Bob Proulx wrote:
> The original option letter used by test to check for the presence of a
> symlink was -h.  I don't know why.  But in those days the only test
> option to test for a symlink was -h.  The -L came later.  This legacy
> is still visible in the HP-UX test man page for example.  No -L
> documented there.
> 
>   http://nixdoc.net/man-pages/HP-UX/man1/test.1.html

The -L option of test(1) actually does work, despite this:

imadev:~$ ls -l symlink 
lrwxr-xr-x   1 wooledg    pgmr             8 May  3  2012 symlink -> notafile
imadev:~$ /bin/test -L symlink; echo $?
0
imadev:~$ uname -a
HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license

The HP-UX Bourne shell requires the -h option though:

imadev:~$ /usr/old/bin/sh -c 'test -L symlink; echo $?'
/usr/old/bin/sh: test: argument expected
imadev:~$ /usr/old/bin/sh -c 'test -h symlink; echo $?'
0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]