develooper Front page | perl.perl5.porters | Postings from December 2011

[perl #107350] perlrun problem causing -S switch not to work correctly on FreeBSD 8.2 for perl versions including 5.8-5.12

Thread Next
ant @ ldeo . columbia . edu
December 31, 2011 15:58
[perl #107350] perlrun problem causing -S switch not to work correctly on FreeBSD 8.2 for perl versions including 5.8-5.12
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #107350]
# 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.12.4.


I have the following two perl-scripts:

    while (<>) {
        print unless m{^#};

    #!/usr/bin/perl -S printfile
    Hello world!

Both are set to executable and placed somewhere in the $PATH, possibly
in different directories. On most UN*X systems I have access to,
including FreeBSD 5.4, MacOSX 10.*, and a couple of Linux boxes, the
command "printme" will produce "Hello world!". On FreeBSD 8.2, however,
it produces the following error message:

    Can't emulate -S on #! line at ./printme line 1.

I traced the problem and found that on other UN*X systems, "printme"
will lead to execution of "perl -S printfile printme" but on FreeBSD 8.2
the code to be executed is "perl '-S printfile' printme". It appears
that somewhere between FreeBSD 5.4 and 8.2 the semantics of the parsing
of #! was modified and this modification broke the -S switch in perl
when used as above.

I have solved the problem with the following patch in perl versions
5.8.9 and 5.12.4:
    - search for the code:
            case 'S':
                forbid_setid('S', FALSE);
                dosearch = TRUE;
                goto reswitch;
    - and insert the following just before the goto:
            #if 1
               { char *s1 = s;
                  while (isSPACE(*s1)) s1++;
                  argv[0] = s1;
                  argc++; argv--;

I believe that this patch is innocuous for perl running on other
systems, although there may be issues if there are systems that support
quotation in #! lines. 

[Please do not change anything below this line]
Site configuration information for perl 5.12.4:

Configured by root at Wed Dec  7 18:35:25 UTC 2011.

Summary of my perl5 (revision 5 version 12 subversion 4) configuration:
    osname=freebsd, osvers=8.2-release-p3, archname=amd64-freebsd
    uname='freebsd 8.2-release-p3 freebsd 8.2-release-p3 #0: tue sep 27 18:45:57 utc 2011 amd64 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.12.4/mach -Dprivlib=/usr/local/lib/perl5/5.12.4 -Dman3dir=/usr/local/lib/perl5/5.12.4/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.12.4/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.12.4 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.12.4/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dinc_version_list=none -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.12.4/BSDPAN" -Doptimize=-O2 -pipe -fno-strict-aliasing -Ui_gdbm -Dusethreads=n -Dusemymalloc=n -Duse64bitint'
    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 ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.12.4/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O2 -pipe -fno-strict-aliasing',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.12.4/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 20070719  [FreeBSD]', 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', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -Wl,-E  -fstack-protector -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.12.4/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib -fstack-protector'

Locally applied patches:

@INC for perl 5.12.4:

Environment for perl 5.12.4:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    PERL_RL= o=0

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