develooper Front page | perl.perl5.porters | Postings from August 2013

[perl #119419] system LIST on Win32 doesn't quote accurately

Thread Previous
Graham Knop
August 22, 2013 19:46
[perl #119419] system LIST on Win32 doesn't quote accurately
Message ID:
# New Ticket Created by  Graham Knop 
# Please include the string:  [perl #119419]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.39 running under perl 5.18.0.


Program arguments on Win32 are passed as a single string, which is
then parsed by the program on startup.  While it's possible for a
program to do arbitrary parsing of the command line string, almost
all programs either use the routine provided by the MS standard C
library, or a routine with compatible rules.

For system LIST to work, perl must assemble the list into a single
string.  But the strings it generates aren't always compatible with
the standard parsing rules.  Attached is a test script that shows
multiple strings that aren't quoted properly.

cmd.exe uses a different set of parsing rules from the C runtime.  It
isn't possible to consistently generate strings that will be handled
the same by cmd.exe and the standard C routine.  This can be
problematic because in some cases, perl will re-try failed system
calls using cmd.exe.

I have a module on CPAN, Win32::ShellQuote, that will quote things
properly for Win32.

Site configuration information for perl 5.18.0:

Configured by gknop at Sat May 18 11:37:06 EDT 2013.

Summary of my perl5 (revision 5 version 18 subversion 0) configuration:
  Commit id: a9acda3b5f74585852a57b51b724804ac586cb0b
    osname=darwin, osvers=12.3.0, archname=darwin-2level
    uname='darwin cuneus 12.3.0 darwin kernel version 12.3.0: sun jan
6 22:37:10 pst 2013; root:xnu-2050.22.13~1release_x86_64 x86_64 '
    config_args='-des -Dusedevel -Uversiononly
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='
-fstack-protector -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-lgdbm -ldbm -ldb -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup
-L/usr/local/lib -L/opt/local/lib -fstack-protector'

Locally applied patches:

@INC for perl 5.18.0:

Environment for perl 5.18.0:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About