develooper Front page | perl.perl5.porters | Postings from September 2012

[perl #114986] Win32: -e '"' always returns true

Thread Next
From:
Sisyphus
Date:
September 20, 2012 22:00
Subject:
[perl #114986] Win32: -e '"' always returns true
Message ID:
rt-3.6.HEAD-11172-1348203587-30.114986-75-0@perl.org
# New Ticket Created by  "Sisyphus" 
# Please include the string:  [perl #114986]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=114986 >


Subject: Win32: -e '"' always returns true
Message-Id: <5.16.0_1816_1348202385@desktop2>
Reply-To: sisyphus1@optusnet.com.au
To: perlbug@perl.org
From: sisyphus1@optusnet.com.au


This is a bug report for perl from sisyphus1@optusnet.com.au,
generated with the help of perlbug 1.39 running under perl 5.16.0.

Hi,

This (raised recently at http://www.perlmonks.org/index.pl?node_id=979494) 
must surely have come up before ?

It's behaviour that's specific to MS Windows - for all versions of perl back 
to 5.6.2 (and presumably even further back).

###############################

use warnings;
use strict;

print "1:  huh?\n" if -e '"';
print "2:  huh?\n" if -e '""';
print "3:  huh?\n" if -e '"""';
print "4:  huh?\n" if -e '""""';
print "5:  huh?\n" if -e '"""""';
print "6:  huh?\n" if -e '""""""""""""""';
print "7:  huh?\n" if defined -f '"';
print "8:  huh?\n" if defined -f '""';
print "9:  huh?\n" if defined -f '"""';
print "10: huh?\n" if defined -f '""""';
print "11: huh?\n" if defined -f '"""""';
print "12: huh?\n" if defined -f '""""""""""""""';

__END__
Outputs:

1:  huh?
2:  huh?
3:  huh?
4:  huh?
5:  huh?
6:  huh?
7:  huh?
8:  huh?
9:  huh?
10: huh?
11: huh?
12: huh?

###############################

That's pretty astounding at first glance - given that the doublequote symbol 
is an illegal filename character.

Apparently this behaviour results from a Windows system practice of treating 
the doublequote symbol as meaning 'everything', and some people might hold 
the view that the output of the above demo is correct behaviour.
As I understand it, -e '"' will currently return true on Windows because 
it's effectively asking "does anything exist in the cwd?" ... and something 
always exists in the cwd (even if it's just the '.' and '..' directories).

For me, this behaviour just doesn't DWIM at all, and it also doesn't match 
the -X documentation, imo.

Dunno ... I'll leave it up to p5p to decide how this should be handled.

My view is that if the behaviour is to be kept as is, then we should at 
least display a notice about this in the -X docs. Something like:

NOTE: On MS windows, if the specified filename consists solely of one
      or more doublequote symbols (") then -e will return true, and
      -f will return false but defined.

And perhaps a similar notice for 'stat' in the perlfunc and perlport docs.
Note that stat('"') returns the same as stat('.').

Cheers,
Rob

---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.16.0:

Configured by Rob at Mon May 28 14:31:11 2012.

Summary of my perl5 (revision 5 version 16 subversion 0) configuration:

  Platform:
    osname=MSWin32, osvers=6.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=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 
=' -s -O2 -DWIN32  -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS 
 -fno-strict-aliasing -mms-bitfields',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.5.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long long', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"c:\MinGW\perl516\lib\CORE" -L"C:\MinGW\lib"'
    libpth=C:\MinGW\lib C:\MinGW\msys\1.0\local\lib 
C:\MinGW\msys\1.0\local\ssl\lib
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 
 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion 
 -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 
 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion 
 -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl516.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', 
lddlflags='-mdll -s -L"c:\MinGW\perl516\lib\CORE" -L"C:\MinGW\lib"'

Locally applied patches:


---
@INC for perl 5.16.0:
    C:\_32\mpfr_dec64_516\lib\perl5\MSWin32-x86-multi-thread
    C:/MinGW/perl516/site/lib
    C:/MinGW/perl516/lib
    .

---
Environment for perl 5.16.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Windows 
NT\Accessories;C:\MinGW\bin;C:\_32\dmake;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\batch;C:\_32\lzma;C:\MinGW\perl516\bin;C:\MinGW\msys\1.0\bin;C:\_32\Gnuplot\binary;C:\sisyphusion\libgcc_straw32
    PERL5LIB=;C:\_32\mpfr_dec64_516\lib\perl5\MSWin32-x86-multi-thread
    PERL_BADLANG (unset)
    SHELL (unset)


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About