| Deutsch English Français Italiano |
|
<v9d05j$39sk8$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968 <aotto1968@t-online.de>
Newsgroups: comp.lang.tcl
Subject: a trivial and complicated problem in TCL
Date: Mon, 12 Aug 2024 14:45:39 +0200
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <v9d05j$39sk8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 12 Aug 2024 14:45:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="77bbed4c9b35fac7f9ab1b40e94fc801";
logging-data="3469960"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MqtxJKa9yX8JRsHu+EZA7U3E2GpcCnWA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rLJndgoMNw0Dg4eM8YUxus3/y7w=
Content-Language: en-US
Bytes: 2355
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 ?