List Info

Thread: in place editing of files does not work outside main loop




in place editing of files does not work outside main loop
user name
2007-03-31 04:29:33
# New Ticket Created by  Elmar Stellnberger 
# Please include the string:  [perl #42253]
# in the subject line of all future correspondence about
this issue. 
# <URL: h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=42253 >


This is a bug report for perl from estellnbyahoo.de,
generated with the help of perlbug 1.35 running under perl
v5.8.8.


------------------------------------------------------------
-----
[Please enter your report here]

In place editing of files with the -i command line switch
does work
inside the main loop only.
Nevertheless it is also supposed to be usable for prepending
and
appending data to the file being modified.
i.e. the "select(STDOUT);" to revert IO before
termination must not be
executed before any user command (specified by any -e)
including those
in the END-sections.

The following perl call should append an inline for
/etc/autobash.sh to
the $usrdir/.bashrc if and only if that file is not already
inlined by
$usrdir/.bashrc:

 perl -ne 'BEGIN{my $hug=0} END{if($hug==0){print ".
/etc/autobash.shn"};} s#auto.sh#autobash.sh#; print
$_;
if(m#^W*(source|.)W+/etc/autobash.sh(;|W*$)#){$hug++}'
       -i $usrdir/.bashrc

or

 perl  -e 'BEGIN{my $hug=0} END{if($hug==0){print ".
/etc/autobash.shn"};}' 
      -pe 's#auto.sh#autobash.sh#;
if(m#^W*(source|.)W+/etc/autobash.sh(;|W*$)#){$hug++}'
       -i $usrdir/.bashrc

A better readable solution to begin/end blocks could even be
the usage
of mere -e blocks at first/last:

 perl  -e 'my $hug=0' 
      -pe 's#auto.sh#autobash.sh#;' 
      -ne
'if(m#^W*(source|.)W+/etc/autobash.sh(;|W*$)#){$hug++}' 

       -e 'if($hug==0){print ".
/etc/autobash.shn"}' 
       -i $usrdir/.bashrc

Currently the 'print ". /etc/autobash.shn"' will
be redirected to
stdout instead of the $usrdir/.bashrc if called directly
from the
command line. Whenever it is called from a bash script the
output of
'print ". /etc/autobash.shn"' is simply lost.

[Please do not change anything below this line]
------------------------------------------------------------
-----
---
Flags:
    category=core
    severity=low
---
This perlbug was built using Perl v5.8.8 - Sun Apr 23
00:25:53 UTC 2006
It is being executed now by  Perl v5.8.8 - Sun Apr 23
00:20:53 UTC 2006.

Site configuration information for perl v5.8.8:

Configured by abuild at Sun Apr 23 00:20:53 UTC 2006.

Summary of my perl5 (revision 5 version 8 subversion 8)
configuration:
  Platform:
    osname=linux, osvers=2.6.16,
archname=i586-linux-thread-multi
    uname='linux tait 2.6.16 #1 smp tue mar 14 18:04:33 utc
2006 i686
i686 i386 gnulinux '
    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr
-Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm
-Di_gdbm
-Duseshrplib=true -Doptimize=-O2 -march=i586 -mtune=i686
-fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -Wall
-pipe'
    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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE
-DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -pipe
-Wdeclaration-after-statement
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -march=i586 -mtune=i686 -fmessage-length=0
-Wall
-D_FORTIFY_SOURCE=2 -g -Wall -pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING
-fno-strict-aliasing -pipe -Wdeclaration-after-statement'
    ccversion='', gccversion='4.1.0 (SUSE Linux)',
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='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =''
    libpth=/lib /usr/lib /usr/local/lib
    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.4.so, so=so, useshrplib=true,
libperl=libperl.so
    gnulibc_version='2.4'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.8/i586-linux-thread-multi/CORE
'
    cccdlflags='-fPIC', lddlflags='-shared'

Locally applied patches:
    

---
INC
for perl v5.8.8:
    /usr/lib/perl5/5.8.8/i586-linux-thread-multi
    /usr/lib/perl5/5.8.8
    /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl
   
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    .

---
Environment for perl v5.8.8:
    HOME=/home/elm
    LANG=de_DE.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=./:/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/opt/kde
3/bin:/usr/lib/qt3/bin/:/opt/gnome/bin:/etc/init.d:/sbin:/us
r/local/sbin:/usr/sbin:/opt/kde3/sbin:/opt/gnome/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )