From Newsgroup: comp.lang.tcl
Hi,
I use
pkg_mkIndex -verbose . {*}$libs
to build a 'pkgIndex.tcl' file … GOOD
NOW I want to redirect the "stderr" output (-verbose) to stdout ... BAD
I can't figure out a "trivial" solution for this simple task IN tcl.
I know there are "exec/open" etc command there I can redirect the output of an EXTERNAL program
but this is not for a tcl INTERNAL "proc" like "pkg_mkIndex".
I know that I can start an second tclsh with the "pkg_mkIndex" and redirect the output BUT
I search for an tcl INTERNAL solution.
my CURRENT solution is way-to-over-engineerd
→ recreate the tcl "put" command and exchange "stderr" with "stdout"
=========================================
# ERASE "stderr" from tcl output
rename puts __tcl__puts
proc puts {args} {
set nxt [lindex $args 0]
if {[string index $nxt 0] eq "-"} {
set nnl $nxt
set args [lassign $args -]
} else {
set nnl ""
}
set nxt [lindex $args 0]
if {[llength [chan names $nxt]]} {
if {$nxt eq "stderr"} {
set chn stdout
} else {
set chn $nxt
}
set args [lassign $args -]
} else {
set chn ""
}
__tcl__puts {*}[concat $nnl $chn $args]
}
=======================================
What I look for is something like:
chan redirect /dev/stderr /dev/stdout
which works without touching any TCL related "proc" stuff or
spawn an extra shell.
→ any idea ?
--- Synchronet 3.20a-Linux NewsLink 1.114