[90610] trunk/base/src/port1.0/portutil.tcl

raimue at macports.org raimue at macports.org
Fri Mar 9 15:48:30 PST 2012


Revision: 90610
          http://trac.macports.org/changeset/90610
Author:   raimue at macports.org
Date:     2012-03-09 15:48:30 -0800 (Fri, 09 Mar 2012)
Log Message:
-----------
Handle reinplace -W to set a common base dir for all file arguments

Modified Paths:
--------------
    trunk/base/src/port1.0/portutil.tcl

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2012-03-09 22:41:58 UTC (rev 90609)
+++ trunk/base/src/port1.0/portutil.tcl	2012-03-09 23:48:30 UTC (rev 90610)
@@ -918,13 +918,13 @@
 # reinplace
 # Provides "sed in place" functionality
 proc reinplace {args}  {
-
-    global env
+    global env worksrcpath
     set extended 0
     set suppress 0
     set oldlocale_exists 0
     set oldlocale "" 
     set locale ""
+    set dir ${worksrcpath}
     while 1 {
         set arg [lindex $args 0]
         if {[string index $arg 0] eq "-"} {
@@ -944,6 +944,10 @@
                 n {
                     set suppress 1
                 }
+                W {
+                    set dir [lindex $args 0]
+                    set args [lrange $args 1 end]
+                }
                 - {
                     break
                 }
@@ -956,12 +960,16 @@
         }
     }
     if {[llength $args] < 2} {
-        error "reinplace ?-E? pattern file ..."
+        error "reinplace ?-E? ?-n? ?-W dir? pattern file ..."
     }
     set pattern [lindex $args 0]
     set files [lrange $args 1 end]
 
     foreach file $files {
+        # if $file is an absolute path already, file join will just return the
+        # absolute path, otherwise it is $dir/$file
+        set file [file join $dir $file]
+
         if {[catch {set tmpfile [mkstemp "/tmp/[file tail $file].sed.XXXXXXXX"]} error]} {
             global errorInfo
             ui_debug "$errorInfo"
@@ -989,6 +997,7 @@
         if {$locale != ""} {
             set env(LC_CTYPE) $locale
         }
+        ui_debug "Executing reinplace: $cmdline"
         if {[catch {eval exec $cmdline} error]} {
             global errorInfo
             ui_debug "$errorInfo"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120309/73ca4111/attachment.html>


More information about the macports-changes mailing list