Skip Menu |

This queue is for tickets about the File-Find-Rule CPAN distribution.

Report information
The Basics
Id: 64504
Status: new
Priority: 0/
Queue: File-Find-Rule

Owner: Nobody in particular
Requestors: user42 [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: grep() can truncate files
Date: Thu, 06 Jan 2011 07:47:10 +1100
To: bug-File-Find-Rule [...]
From: Kevin Ryde <user42 [...]>
Download (untitled) / with headers
text/plain 678b
With File::Find::Rule and recent debian i386 perl 5.10.1, the program below truncates file /tmp/zzz/foo to zero length, where I hoped a File::Find::Rule grep() would be read-only. I think the filename ">foo" in the directory causes open FILE, $_ or return; to overwrite the "foo" file. I suppose only the 3-arg open treats all weird filenames properly. If staying 2-arg for older perl compatibility then a "<$filename", or a "<./$filename" if not an absolute filename already, might help avoid the worst. Either way it could be worth showing 3-arg in the POD sample exec() under the "Further examples", to keep cut-and-paste users out of this kind of trouble.
text/x-perl 340b
# create two files /tmp/zzz/foo and /tmp/zzz/>foo system " rm -r /tmp/zzz mkdir /tmp/zzz echo abc def >/tmp/zzz/foo echo abc def >'/tmp/zzz/>foo' ls -l /tmp/zzz "; # grep them ... use File::Find::Rule; my @files = File::Find::Rule->grep('abc')->in('/tmp/zzz'); # /tmp/zzz/foo has been truncated to 0 length ... system ("ls -l /tmp/zzz");

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to