Groovy
  1. Groovy
  2. GROOVY-820

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-1
    • Fix Version/s: 1.0-JSR-3
    • Component/s: None
    • Labels:
      None

      Description

      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.

      1. patchfile.txt
        0.6 kB
        Tom White

        Activity

        Tom White created issue -
        Dierk König made changes -
        Field Original Value New Value
        Fix Version/s 1.0-JSR-3 [ 11518 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12729970 ] Default workflow, editable Closed status [ 12741897 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12968416 ] Default workflow, editable Closed status [ 12976207 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Tom White
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development