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 replacement command changes symbolic links into files and always touches all files #13959

Open
p5pRT opened this issue Jun 27, 2014 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 27, 2014

Migrated from rt.perl.org#122186 (status was 'open')

Searchable as RT122186$

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2014

From yuri@rawbw.com

perl -pi -e "s/blahblah/blah/g" * always converts symbolic links into
files (even when no replacement actually happens).

Another related problem is that such in place command touches all files
regardless of if replacement is done or not.

v5.16.3 on FreeBSD-9

Yuri

@p5pRT
Copy link
Author

p5pRT commented Jun 29, 2014

From @jkeenan

On Fri Jun 27 14​:22​:17 2014, yuri@​rawbw.com wrote​:

perl -pi -e "s/blahblah/blah/g" * always converts symbolic links into
files (even when no replacement actually happens).

Another related problem is that such in place command touches all files
regardless of if replacement is done or not.

You're getting what you asked Perl to do.

As is documented in 'perldoc perlrun', the '-i' switch "specifies that files processed by the "<>" construct are to be edited in-place. It does this by renaming the input file, opening the output file by the original name, and selecting that output file as the default for print() statements."

'perlrun' goes on to note​:

"Note that because -i renames or deletes the original file before creating a new file of the same name, Unix-style soft and hard links will not be preserved."

Moreover, when you provide '*' for the files to be processed by the "<>" construct, you are saying, "Process all the files in this directory." And since, the processing you have requested ("-pi") calls for renaming or deletion of the original files, the files are necessarily "touched."

This is Perl's documented behavior. Such behavior dates back many years, probably to the dawn of Perl. Are you advocating a change in that behavior?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Jun 29, 2014

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants