Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/replace.tcl # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / replace.tcl` 23 lines ยท 709 bytes Raw Blame History 1 #!/usr/bin/tcl 2 # 3 # Replace string with another string -OR- include 4 # only lines successfully modified with a regular 5 # expression. 6 # 7 fconfigure stdout -translation binary 8 fconfigure stderr -translation binary 9 set mode [string tolower [lindex $argv 0]] 10 set from [lindex $argv 1] 11 set to [lindex $argv 2] 12 if {-1 == [lsearch -exact [list exact regsub include] $mode]} {exit 1} 13 if {[string length $from]==0} {exit 2} 14 while {![eof stdin]} { 15 set line [gets stdin] 16 if {[eof stdin]} break 17 switch -exact $mode { 18 exact {set line [string map [list $from $to] $line]} 19 regsub {regsub -all -- $from $line $to line} 20 include {if {[regsub -all -- $from $line $to line]==0} continue} 21 } 22 puts stdout $line 23 }