Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl -e "open A, 'dir|';print $?" should be 0 on MSWin32 #16664

Open
p5pRT opened this issue Aug 21, 2018 · 3 comments
Open

perl -e "open A, 'dir|';print $?" should be 0 on MSWin32 #16664

p5pRT opened this issue Aug 21, 2018 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 21, 2018

Migrated from rt.perl.org#133463 (status was 'open')

Searchable as RT133463$

@p5pRT
Copy link
Author

p5pRT commented Aug 21, 2018

From Vadim.Konovalov@dell.com

Created by vadim.konovalov@dell.commailto:vadim.konovalov@dell.com

For this simple one-liner
  perl -e "open A, 'dir|';print $?"
different perl versions on Win32 mostly output -1
but not all (5.8.4 outputs 0)

D​:\apps\perl-old\perl584\bin>perl -e "open A, 'dir|';print $?"
0
D​:\apps\perl-old\perl5121\bin>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl-5.16.0>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl-5-004-02>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl5_005_03>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl561>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-5.28.0\perl\bin>perl -e "open A, 'dir|';print $?"
-1

on Cygwin this outputs 0 as expected, as well as on linux freebsd etc

reading "perldoc perlvar" gives me think that it should output 0

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.27.9:

Configured by konovv at Tue Feb 27 18:23:50 2018.

Summary of my perl5 (revision 5 version 27 subversion 9) configuration:

  Platform:
    osname=MSWin32
    osvers=10.0.14393
    archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=undef
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags =' -s -O2 -DWIN32  -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='7.1.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=4
    doublesize=8
    byteorder=1234
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=12
    longdblkind=3
    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:\perl\lib\CORE" -L"C:\MinGW\lib"'
    libpth=C:\MinGW\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=libperl527.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"c:\perl\lib\CORE" -L"C:\MinGW\lib"'



@INC for perl 5.27.9:
    C:\Work\PerlScripts\utl
    C:\Work\PerlScripts\mfdev
    C:\Personal\perlutl
    C:/vad/perl-dev/perl-compile/perl-5.27.9/lib


Environment for perl 5.27.9:
    HOME=c:\apps
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Haskell\bin;C:\apps\Haskell-p-8.2.2\lib\extralibs\bin;C:\apps\Haskell-p-8.2.2\bin;C:\apps\vim80.1157;C:\apps\perl-5.26.0-32\c\bin;C:\apps\perl-5.26.0-32\perl\site\bin;C:\apps\perl-5.26.0-32\perl\bin;C:\apps\tcl-866-as86\bin;C:\apps\Python27;C:\apps\clisp-2.49;C:\Work\apps\report;C:\Work\apps;C:\apps\pandoc;C:\apps\emacs\bin;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\EMC\;c:\sh;C:\Program Files\Dell\Dell Data Protection\Encryption\;C:\apps\ggobi;C:\apps\Haskell-p-8.2.2\mingw\bin;C:\Users\konovv\AppData\Roaming\cabal\bin;C:\apps\haskell-p-8.2.2\Roaming\local\bin;C:\Users\konovv\.cargo\bin;C:\Users\konovv\AppData\Local\Microsoft\WindowsApps;C:\rakudo\bin;C:\rakudo\share\perl6\site\bin
    PERL5LIB=C:\Work\PerlScripts\utl;C:\Work\PerlScripts\mfdev;C:\Personal\perlutl
    PERL_BADLANG (unset)
    SHELL (unset)



@p5pRT
Copy link
Author

p5pRT commented Sep 6, 2018

From @tonycoz

On Tue, 21 Aug 2018 13​:06​:20 -0700, Vadim.Konovalov@​dell.com wrote​:

For this simple one-liner
perl -e "open A, 'dir|';print $?"
different perl versions on Win32 mostly output -1
but not all (5.8.4 outputs 0)

D​:\apps\perl-old\perl584\bin>perl -e "open A, 'dir|';print $?"
0
D​:\apps\perl-old\perl5121\bin>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl-5.16.0>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl-5-004-02>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl5_005_03>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-old\perl561>perl -e "open A, 'dir|';print $?"
-1
D​:\apps\perl-5.28.0\perl\bin>perl -e "open A, 'dir|';print $?"
-1

on Cygwin this outputs 0 as expected, as well as on linux freebsd etc

reading "perldoc perlvar" gives me think that it should output 0

Possibly introduced (at least for NT-ish systems) by 40c7cc6.

I don't see anything in the documentation for open() nor for $?
indicating that $? is modified by open(), nor that it's modified
by open.

The behaviour you're seeing on Linux isn't that open is setting $? to 0, it just isn't touching it​:

  $ perl -le '$? = -1; open F, "ls |"; print $?'
  -1

So perhaps pp_open() should be preserving PL_statusvalue ($?).

Not that I can see much reason for you to be checking $? after a successful open.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants