Ticket #15514: reinplace-warning3.diff

File reinplace-warning3.diff, 1.3 KB (added by raimue (Rainer Müller), 12 years ago)

Added a -f option

  • src/port1.0/portutil.tcl

     
    718718# Provides "sed in place" functionality
    719719proc reinplace {args}  {
    720720    set extended 0
     721    set force 0
    721722    while 1 {
    722723        set arg [lindex $args 0]
    723724        if {[string index $arg 0] eq "-"} {
     
    726727                E {
    727728                    set extended 1
    728729                }
     730                f {
     731                    set force 1
     732                }
    729733                - {
    730734                    break
    731735                }
     
    738742        }
    739743    }
    740744    if {[llength $args] < 2} {
    741         error "reinplace ?-E? pattern file ..."
     745        error "reinplace ?-f? ?-E? pattern file ..."
    742746    }
    743747    set pattern [lindex $args 0]
    744748    set files [lrange $args 1 end]
     
    776780   
    777781        close $tmpfd
    778782   
     783        if {$force == 0 && ![catch {exec cmp -s $file $tmpfile}]} {
     784            ui_warn "[format [msgcat::mc "reinplace %1\$s didn't change anything in %2\$s"] $pattern $file]"
     785        }
     786   
    779787        set attributes [file attributes $file]
    780788        # We need to overwrite this file
    781789        if {[catch {file attributes $file -permissions u+w} error]} {