0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-11-24 16:18:08 +01:00
sqlite/tool/replace.tcl
mistachkin 52b1dbb5fc Allow the 'testfixture.exe' target to be compiled with the __stdcall calling convention.
FossilOrigin-Name: e8be3dfeabaa31b3490793cf8230faae1204be15
2016-07-28 14:37:04 +00:00

22 lines
613 B
Tcl

#!/usr/bin/tcl
#
# Replace string with another string -OR- include
# only lines successfully modified with a regular
# expression.
#
set mode [string tolower [lindex $argv 0]]
set from [lindex $argv 1]
set to [lindex $argv 2]
if {$mode ni [list exact regsub include]} {exit 1}
if {[string length $from]==0} {exit 2}
while {![eof stdin]} {
set line [gets stdin]
if {[eof stdin]} break
switch -exact $mode {
exact {set line [string map [list $from $to] $line]}
regsub {regsub -all -- $from $line $to line}
include {if {[regsub -all -- $from $line $to line]==0} continue}
}
puts stdout $line
}