Issue Details (XML | Word | Printable)

Key: GROOVY-820
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Tom White
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

GroovyMain command line switch -i fails when no backup extension is specified

Created: 17/Apr/05 06:03 PM   Updated: 18/Jul/05 01:00 PM   Resolved: 18/Jul/05 01:00 PM
Return to search
Component/s: None
Affects Version/s: 1.0-JSR-1
Fix Version/s: 1.0-JSR-3

Time Tracking:
Not Specified

File Attachments: 1. Text File patchfile.txt (0.6 kB)



 Description  « Hide

The command

groovy -pi -e "(line =~ 'a').replaceAll('b')" ok.txt

fails with

Caught: java.io.IOException: unable to rename ok.txt to C:\DOCUME~1\TOMWHI~1\LOC
ALS~1\Temp\groovy_61377.tmp

whereas

groovy -pi.bak -e "(line =~ 'a').replaceAll('b')" ok.txt

works fine.

The problem is that after creating a temporary backup file using File.createTempFile() the code needs to delete it before renaming the original to the backup.

The attached patch file fixes the problem.



Dierk Koenig added a comment - 18/Jul/05 01:00 PM

applied the patch.

Hi Tom! Nice Blog! and thanx for the posting