develooper Front page | perl.perl5.porters | Postings from July 2016

[perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
July 5, 2016 23:50
Subject:
[perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?
Message ID:
rt-4.0.18-14780-1467762632-274.24000-15-0@perl.org
On Tue Jul 05 15:47:08 2016, dcollinsn@gmail.com wrote:
> Confirmed in blead.
> 
> I definitely thing this is a bug that needs to be repaired. At
> minimum, as suggested, I think a warning would be helpful when the
> target file is a symlink that is not being followed. After all, this
> is "like sed", as perl -h says. If you're following the link to read
> the file, you should also follow the link to write it.

According to its documentation, the default for GNU sed is to break the
symlink:

`--follow-symlinks'
     This option is available only on platforms that support symbolic
     links and has an effect only if option `-i' is specified.  In this
     case, if the file that is specified on the command line is a
     symbolic link, `sed' will follow the link and edit the ultimate
     destination of the link.  The default behavior is to break the
     symbolic link, so that the link destination will not be modified.

which is the behaviour I expected.

(POSIX, BSD, Solaris sed don't seem to support in-place editing.)

My work in progress in-place edit branch doesn't attempt to follow symlinks.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=24000

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About