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

in-place edit does not replace files during non-global cleanup #16781

Open
p5pRT opened this issue Dec 3, 2018 · 1 comment
Open

in-place edit does not replace files during non-global cleanup #16781

p5pRT opened this issue Dec 3, 2018 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Dec 3, 2018

Migrated from rt.perl.org#133709 (status was 'new')

Searchable as RT133709$

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2018

From @tonycoz

Created by @tonycoz

[perl #133659] reported a problem where the in-place edit input file
wasn't replaced with the output file during global clean-up.

That specific problem was fixed[1] but a more difficult to solve case
like​:

sub foo {
  local (*ARGV, *ARGVOUT);
  @​ARGV = @​_;
  my $d = do { local $/; <> };
  $d =~ s/FAILED/OK/ or die;
  print $d;
}
eval { foo("somefile") };

doesn't replace the file on apparent success.

To solve that problem we need to be able to detect whether the current
unwinding is due to die or normal clean up, and there's no current
mechanism for that.

https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133659#txn-1595418

includes an attempt at adding such a mechanism, but fails its own
tests.

Since the reported problem was fixed, I'll be closing the original
ticket, this ticket preserves the more difficult case.

[1] https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133659#txn-1596249

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.29.6:

Configured by tony at Mon Dec  3 16:00:04 AEDT 2018.

Summary of my perl5 (revision 5 version 29 subversion 6) configuration:
  Commit id: bf5c7c7dda5ab51eb76dfb8282ec8fa20cea9363
  Platform:
    osname=linux
    osvers=4.9.0-8-amd64
    archname=x86_64-linux
    uname='linux mars 4.9.0-8-amd64 #1 smp debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 gnulinux '
    config_args='-des -Dusedevel -DDEBUGGING -Doptimize=-O0 -g'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O0 -g'
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='6.3.0 20170516'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/6/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.24.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.24'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O0 -g -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.29.6:
    lib
    /usr/local/lib/perl5/site_perl/5.29.6/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.29.6
    /usr/local/lib/perl5/5.29.6/x86_64-linux
    /usr/local/lib/perl5/5.29.6


Environment for perl 5.29.6:
    HOME=/home/tony
    LANG=en_AU.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/tony/perl5/perlbrew/bin:/home/tony/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERLBREW_BASHRC_VERSION=0.43
    PERLBREW_HOME=/home/tony/.perlbrew
    PERLBREW_MANPATH=
    PERLBREW_PATH=/home/tony/perl5/perlbrew/bin
    PERLBREW_ROOT=/home/tony/perl5/perlbrew
    PERLBREW_VERSION=0.67
    PERL_BADLANG (unset)
    SHELL=/bin/bash

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