3 Jul 23:34
Re: Future [exec] overhaul
From: Andreas Leitgeb <avl@...>
Subject: Re: Future [exec] overhaul
Newsgroups: gmane.comp.lang.tcl.core
Date: 2008-07-03 21:34:59 GMT
Subject: Re: Future [exec] overhaul
Newsgroups: gmane.comp.lang.tcl.core
Date: 2008-07-03 21:34:59 GMT
"Alexandre Ferrieux" <alexandre.ferrieux@...> wrote: > In a future TIP I will propose a new, extended [exec] (all options are > still open as to the script API: [exec -extended], [exec -list], > [exec2], you name it...), with the following main targets: > (1) Fix the impossibility to pass > < | etc. as isolated arguments. Some year ago I proposed a new option to classic exec, that would cause some special quote-char to be eaten away from each arg that starts with it. The proposed syntax was really ugly, but it solved problem (1). I didn't ever TIP it, because I found it so ugly, myself. Anyway, it might still be reconsidered, as a low-level building block for a high-level exec2 (painted whichever color), which then could be done in pure tcl based on old exec with that quote-extra. If you don't remember it, here's an abstract: exec -quoted echo '<hello> '| ''blah' >foo would end up writing the literal string: <hello> | 'blah' into file foo. There are of course a couple of different colors available for painting the option's name. The trick would be, that a first round parses all the usual exec magic arguments, skipping all those starting with that quote-char, since it is not magic to exec. Then, just before really executing the command, it would strip at most one quote-char from each argument, thus making it possible to also have arguments starting with that quote-char. I once had a (technically even uglier) patch for this based on 8.4.3, which didn't cleanly apply to 8.5 and I gave up on it. The old patch still exists. The effect can roughly be experienced w/o change in tcl but with a helper-command, that does the quote-stripping, and calling it like that: exec quotestripper echo '<hello> '| ''blah' | \ quotestripper grep {'<...} >foo Unfortunately the quotestripper cannot be a tcl-script, and it needs to be specified for each part of a multi-command pipeline. The rest applies both, to a real new exec2 sibling of exec, or to a wrapper proc exec2 that builds on exec... > (2) Get rid of complicated legacy rules regarding the scope and > semantics of redirection. These include the csh-style >&, the Good! > (impossible) --> [exec2 foo 2>& $ch1 | bar 2>& $ch2] Ah, now I see, why we must get rid of csh syntax relicts(Otherwise I'd have suggested to leave them in as well) > (3) Generalize on unix to fds above 2 as in Bourne shell and as shown > in the TIP under section "Directions for future work": Good! > (4) Give a means to get the exit status at the end of an [exec2 ... &]. Good, too, but I can't name any favourite color for that. PS: If anyone reads this out of context later, the references to "color" are references to the "bikeshed" parable. <http://en.wikipedia.org/wiki/Color_of_the_bikeshed> ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
(Otherwise I'd have suggested to leave them in as well)
> (3) Generalize on unix to fds above 2 as in Bourne shell and as shown
> in the TIP under section "Directions for future work":
Good!
> (4) Give a means to get the exit status at the end of an [exec2 ... &].
Good, too, but I can't name any favourite color for that.
PS: If anyone reads this out of context later, the references to
"color" are references to the "bikeshed" parable.
<
RSS Feed