People might find this entertaining and/or useful: http://www.gnu.org/manual/autoconf-2.52/html_chapter/autoconf_10.html With the help of Jos Backus I just discovered the answer to http://lists.samba.org/pipermail/rsync-cvs/2002-January/001271.html is that Sun's test(1) is breathtakingly broken when passed a dangling symlink: $ ln -s /nowhere bad $ ls -l bad lrwxrwxrwx 1 josb user 8 Mar 13 20:10 bad -> /nowhere $ if test -L bad; then echo bad; fi test: argument expected $ if test -h bad; then echo bad; fi bad $ -- Martin
On Thu, 2002-03-14 at 01:37, Martin Pool wrote:> People might find this entertaining and/or useful: > > http://www.gnu.org/manual/autoconf-2.52/html_chapter/autoconf_10.html > > With the help of Jos Backus I just discovered the answer to > > http://lists.samba.org/pipermail/rsync-cvs/2002-January/001271.html > > is that Sun's test(1) is breathtakingly broken when passed a dangling > symlink: > > $ ln -s /nowhere bad > $ ls -l bad > lrwxrwxrwx 1 josb user 8 Mar 13 20:10 bad -> /nowhere > $ if test -L bad; then echo bad; fi > test: argument expected > $ if test -h bad; then echo bad; fi > bad > $This does not demonstrate that test(1) is broken. First of all, pretty much every shell these days has test as a builtin, and as such you should be accusing sh(1), ksh(1), or similar. With /bin/sh or /bin/ksh $ ls -l bad lrwxrwxrwx 1 mgerdts foo 8 Mar 14 07:29 bad -> /nowhere $ /bin/test -L bad && echo bad bad $ if /bin/test -L bad ; then echo bad ; fi bad With /bin/sh (SunOS 5.8 Generic 109324-02 February 2001): $ if [ -L bad ] ; then echo bad ; fi test: argument expected $ if test -L bad ; then echo bad ; fi test: argument expected With /bin/ksh (SunOS 5.8 Generic 110662-04 May 2001) $ if [ -L bad ] ; then echo bad ; fi bad $ if test -L bad ; then echo bad ; fi bad Note that /usr/xpg4/bin/sh is a symbolic link to /bin/ksh. Mike
Martin Pool wrote:> is that Sun's test(1) is breathtakingly broken when passed > a dangling symlink: > > $ ln -s /nowhere bad > $ ls -l bad > lrwxrwxrwx 1 josb user 8 Mar 13 20:10 bad -> /nowhere > $ if test -L bad; then echo bad; fi > test: argument expected > $ if test -h bad; then echo bad; fi > badFixed, in Solaris 8, but broken in at least 2.6 and possibly 7. elsbeth> ln -s /nowhere bad you have mail in /var/mail/davecb elsbeth> ls -l bad lrwxrwxrwx 1 davecb staff 8 Mar 14 2002 bad -> /nowhere elsbeth> if test -L bad; then echo bad; fi bad elsbeth> if test -h bad; then echo bad; fi bad --dave -- David Collier-Brown, | Always do right. This will gratify Performance & Engineering | some people and astonish the rest. Americas Customer Engineering, | -- Mark Twain (905) 415-2849 | davecb@canada.sun.com
On Thu, 2002-03-14 at 08:11, David Collier-Brown wrote:> Fixed, in Solaris 8, but broken in > at least 2.6 and possibly 7.Not fixed in Solaris 8: $ ps -fp $$ UID PID PPID C STIME TTY TIME CMD mgerdts 7104 12228 0 11:34:30 pts/1 0:00 /bin/sh $ what /bin/sh /bin/sh: SunOS 5.8 Generic 109324-04 October 2001 $ ls -l foo lrwxrwxrwx 1 mgerdts cns 8 Mar 14 11:34 foo -> /nowhere $ ls -l /nowhere /nowhere: No such file or directory $ if [ -L foo ] ; then echo "foo is a symlink" ;fi test: argument expected $ if test -L foo ; then echo "foo is a symlink" ; fi test: argument expected $ Just a while ago I mentioned that this was broken with rev 02 of the same patch. According to Sunsolve, rev 04 is the latest. Mike
Mike Gerdts wrote:> $ what /bin/sh > /bin/sh: > SunOS 5.8 Generic 109324-04 October 20Aha! Fixed in /bin/test, and in at least ksh but not fixed in sh, which seems to use a builtin! Try if /bin/test -L foo ; then echo "foo is a symlink" ;fi which gives a different result than "test" or "[" --dave -- David Collier-Brown, | Always do right. This will gratify Performance & Engineering | some people and astonish the rest. Americas Customer Engineering, | -- Mark Twain (905) 415-2849 | davecb@canada.sun.com