Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.91k stars 542 forks source link

File test does not return 0 for symbolic links #9475

Closed p5pRT closed 16 years ago

p5pRT commented 16 years ago

Migrated from rt.perl.org#58782 (status was 'resolved')

Searchable as RT58782$

p5pRT commented 16 years ago

From Gunnar.xa.Strand@ericsson.com

Created by Gunnar.xa.Strand@ericsson.com

The documentation for "-X" states that​:

"Unless otherwise documented\, it returns 1 for true and '' for false\, or the undefined value if the file doesn't exist."

The -e operator does not return '' if the argument exists but is a symbolic link.

How to verify​:

% ln -s x y % perl -MData​::Dumper -e 'print Dumper([ -l "y"\, -e "y" ])' $VAR1 = [   1\,   undef   ];

The second list entry should have been ''\, if the documentation had been correct. Or perhaps the implementation is incorrect?

Perl Info ``` Flags: category=docs severity=low Site configuration information for perl v5.8.8: Configured by erabodo at Mon Jun 18 16:14:38 MEST 2007. Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi uname='sunos ws11772 5.8 generic_117350-39 sun4u sparc sunw,sun-blade-1500 ' config_args='-Dcc=gcc -Dprefix=/vobs/cello/cade_struct/tools/perl/SunOS/sparc -Dusethreads' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -fno-strict-aliasing -pipe -Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O', cppflags='-D_REENTRANT -fno-strict-aliasing -pipe -Wdeclaration-after-statement' ccversion='', gccversion='3.4.2', gccosandvers='solaris2.8' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib -L/opt/local/lib ' libpth=/usr/local/lib /opt/local/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lpthread -lc perllibs=-lsocket -lnsl -ldl -lm -lpthread -lc libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib -L/opt/local/lib' Locally applied patches: @INC for perl v5.8.8: /vobs/swdi/tools/lib/perl /home/qstrgun/lib/perl /home/qstrgun/lib/cpan/sun4-solaris-thread-multi /home/qstrgun/lib/cpan /vobs/cello/swdi_config/tools/batch_engine/lib/cpan /vobs/cello/cade_struct/tools/perl/SunOS/sparc/lib/5.8.8/sun4-solaris-thread-multi /vobs/cello/cade_struct/tools/perl/SunOS/sparc/lib/5.8.8 /vobs/cello/cade_struct/tools/perl/SunOS/sparc/lib/site_perl/5.8.8/sun4-solaris-thread-multi /vobs/cello/cade_struct/tools/perl/SunOS/sparc/lib/site_perl/5.8.8 /vobs/cello/cade_struct/tools/perl/SunOS/sparc/lib/site_perl . Environment for perl v5.8.8: HOME=/home/qstrgun LANG=en_US LANGUAGE (unset) LC_COLLATE=en_US.ISO8859-1 LC_CTYPE=en_US.ISO8859-1 LC_MESSAGES=C LC_MONETARY=en_US.ISO8859-1 LC_NUMERIC=en_US.ISO8859-1 LC_TIME=en_US.ISO8859-1 LD_LIBRARY_PATH=/home/qstrgun/opt/lib:/usr/lib:/vobs/cello/cade_struct/SunOS/sparc/lib:/vobs/cello/cade_struct/lib:/vobs/cello/cade_struct/tools/testrt/TestRT/lib/sun4/sunOS5:/vobs/cello/cade_struct/tools/testrt/TestRT/bin/sun4/sunOS5:/vobs/cello/cade_struct/lib/ext:/vobs/cello/cade_struct/local/lib:/home/qstrgun/opt/lib:/home/qstrgun/opt/lib:/opt/pub/src/kde-3.2.2/lib:/opt/pub/src/qt-3.3.1/lib:/opt/pub/src/openssl-0.9.7/lib:/usr/lib:/usr/sfw/lib:/app/glib/1.2.10/lib:/app/gtk+/1.2.10/lib:/home/qstrgun/opt/lib:/opt/pub/lib:/opt/pub/lib:/opt/pub/lib:/opt/pub/lib:.:/opt/pub/lib LOGDIR (unset) PATH=/app/xemacs/21.5.27/bin:/home/qstrgun/bin:/home/qstrgun/opt/bin:/vobs/cello/cade_struct/SunOS/sparc/bin/jdk1.4:/vobs/cello/cade_struct/SunOS/sparc/bin:/vobs/cello/cade_struct/bin:/bin:/usr/bin:/usr/atria/bin:/vobs/cello/cade_struct/bin/ext:/vobs/cello/cade_struct/local/bin:/app/thunderbird/2.0.0.6:/app/firefox/2.0.0.6:/app/mozilla/1.7.12:/app/openoffice/2.3.1/opt/openoffice.org2.3/program:/home/qstrgun/bin:/home/qstrgun/opt/bin:/home/qstrgun/.afs/0/rbin:/home/qstrgun/.afs/0/pbin:/env/seas/bin:/home/qstrgun/.afs/0/ibin:/usr/afsws/bin:/app/arc/0/bin:/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin:/usr/sbin:/sbin:/usr/ucb:/opt/pub/bin:.:/vobs/cello/swdi_config/project/cpp7/bin:/opt/pub/bin PERL5LIB=/vobs/swdi/tools/lib/perl:/home/qstrgun/lib/perl:/home/qstrgun/lib/cpan:/vobs/cello/swdi_config/tools/batch_engine/lib/cpan PERLLIB=/vobs/swdi/tools/lib/perl:/home/qstrgun/lib/perl:/home/qstrgun/lib/cpan:/vobs/cello/cade_struct/tools/build/lib:/vobs/cello/cade_struct/tools/perl/SunOS/sparc/lib PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 16 years ago

From @rgs

2008/9/12 Gunnar.xa.Strand@​ericsson.com (via RT) \perlbug\-followup@​perl\.org​:

The documentation for "-X" states that​:

"Unless otherwise documented\, it returns 1 for true and '' for false\, or the undefined value if the file doesn't exist."

The -e operator does not return '' if the argument exists but is a symbolic link.

That's actually correct. The -X operators do a stat\, not a lstat : thus\, they follow symbolic links\, and are actually testing x\, not y. You should use lstat instead.

$ perl -le 'lstat"y";print -l _\, -e _' 11

p5pRT commented 16 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 16 years ago

module@renee-baecker.de - Status changed from 'open' to 'resolved'