Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #429: Temporal anomaly


comp / comp.lang.tcl / Re: a trivial and complicated problem in TCL

SubjectAuthor
* a trivial and complicated problem in TCLaotto1968
+- Re: a trivial and complicated problem in TCLRalf Fassel
`- Re: a trivial and complicated problem in TCLundroidwish

1
Subject: a trivial and complicated problem in TCL
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 12 Aug 2024 12:45 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
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
View all headers

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 ?

Subject: Re: a trivial and complicated problem in TCL
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Mon, 12 Aug 2024 13:48 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: a trivial and complicated problem in TCL
Date: Mon, 12 Aug 2024 15:48:32 +0200
Lines: 34
Message-ID: <ygattfpzwb3.fsf@akutech.de>
References: <v9d05j$39sk8$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 7xenvsra8ubhXhN4M7WLLwP7TdCeQGTOfGtdTbrEaMYoqd3lQ=
Cancel-Lock: sha1:h4gotZxTLPjYFqy4v49fiz92Xz0= sha1:d3uDBR91q/uDxlSS8oUfInuqUT4= sha256:JEASRV2BB40JSQHBOFtjb7R3s0l/zFYKUEYLHZD1yxs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

* aotto1968 <aotto1968@t-online.de>
| 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.

Looking at the code for pkg_mkIndex, it uses 'tclLog' for the 'verbose'
output. 'tclLog' itself is defined in init.tcl, with the explicit comment

# Define a log command (which can be overwritten to log errors
# differently, specially when stderr is not available)

if {[namespace which -command tclLog] eq ""} {
proc tclLog {string} {
catch {puts s $string}
}
}

So if you redefine

proc tclLog {string} {
catch {puts stdout $string}
}

prior to invoking pkg_mkIndex, it might "just work".

Haven'd tried it, so YMMV.

HTH
R'

Subject: Re: a trivial and complicated problem in TCL
From: undroidwish
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 12 Aug 2024 13:54 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: undroidwish@googlemail.com (undroidwish)
Newsgroups: comp.lang.tcl
Subject: Re: a trivial and complicated problem in TCL
Date: Mon, 12 Aug 2024 15:54:19 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <v9d46c$3anll$1@dont-email.me>
References: <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 15:54:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ea2a9b1c31cda263eee6869693096b7a";
logging-data="3497653"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vIi7OJ16uxR38uRbBDbSJ6SNe8/d6tSQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:BUcV0Kpul92f0AeliboptTL+Qpk=
Content-Language: en-US
In-Reply-To: <v9d05j$39sk8$1@dont-email.me>
View all headers

On 8/12/24 14:45, aotto1968 wrote:

> ...
> my CURRENT solution is way-to-over-engineerd
> → recreate the tcl "put" command and exchange "stderr" with "stdout"

You could have studied the implementation of "pkg_mkIndex" and found
that it uses a command "tclLog" for logging. Then you could have
exchanged the "tclLog" command with the implementation of your choice.
If this is over or under engineering depends solely on your own
version of "tclLog".

HTH,
Christian

1

rocksolid light 0.9.8
clearnet tor