[25450] branches/dp2mp-move/base
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 21 23:27:00 PDT 2007
Revision: 25450
http://trac.macosforge.org/projects/macports/changeset/25450
Author: jmpp at macports.org
Date: 2007-05-21 23:27:00 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Merging Eridius' r25251: Add -E flag to reinplace.
Modified Paths:
--------------
branches/dp2mp-move/base/doc/portfile.7
branches/dp2mp-move/base/src/port1.0/portutil.tcl
Modified: branches/dp2mp-move/base/doc/portfile.7
===================================================================
--- branches/dp2mp-move/base/doc/portfile.7 2007-05-22 06:24:25 UTC (rev 25449)
+++ branches/dp2mp-move/base/doc/portfile.7 2007-05-22 06:27:00 UTC (rev 25450)
@@ -1591,8 +1591,17 @@
.Dl adduser foo gid=[existsgroup foo]
.It Ic nextgid
Returns the highest used gid plus one.
-.It Ic reinplace Ar regex Ar filename
-Provide in-place sed like editing of a file.
+.It Xo
+.Ic reinplace
+.Op Fl E
+.Ar regex
+.Ar
+.Xc
+Provide in-place
+.Xr sed 1
+like editing of a file.
+The -E flag does the same thing as in
+.Xr sed 1
.br
.Sy Example:
.Dl reinplace \*qs|/usr/local|${prefix}|g\*q doc/manpage.1
Modified: branches/dp2mp-move/base/src/port1.0/portutil.tcl
===================================================================
--- branches/dp2mp-move/base/src/port1.0/portutil.tcl 2007-05-22 06:24:25 UTC (rev 25449)
+++ branches/dp2mp-move/base/src/port1.0/portutil.tcl 2007-05-22 06:27:00 UTC (rev 25450)
@@ -661,13 +661,34 @@
# reinplace
# Provides "sed in place" functionality
-proc reinplace {pattern args} {
- if {$args == ""} {
- ui_error "reinplace: no value given for parameter \"file\""
- return -code error "no value given for parameter \"file\" to \"reinplace\""
+proc reinplace {args} {
+ set extended 0
+ while 1 {
+ set arg [lindex $args 0]
+ if {[string first - $arg] != -1} {
+ set args [lrange $args 1 end]
+ switch [string range $arg 1 end] {
+ E {
+ set extended 1
+ }
+ - {
+ break
+ }
+ default {
+ error "reinplace: unknown flag '-$arg'"
+ }
+ }
+ } else {
+ break
+ }
}
+ if {[llength $args] < 2} {
+ error "reinplace ?-E? pattern file ..."
+ }
+ set pattern [lindex $args 0]
+ set files [lrange $args 1 end]
- foreach file $args {
+ foreach file $files {
if {[catch {set tmpfile [mkstemp "/tmp/[file tail $file].sed.XXXXXXXX"]} error]} {
global errorInfo
ui_debug "$errorInfo"
@@ -680,7 +701,12 @@
set tmpfile [lindex $tmpfile 1]
}
- if {[catch {exec sed $pattern < $file >@ $tmpfd} error]} {
+ set cmdline sed
+ if {$extended} {
+ lappend cmdline -E
+ }
+ set cmdline [concat $cmdline [list $pattern < $file >@ $tmpfd]]
+ if {[catch {eval exec $cmdline} error]} {
global errorInfo
ui_debug "$errorInfo"
ui_error "reinplace: $error"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070521/95fa3bf9/attachment.html
More information about the macports-changes
mailing list