On 27/04/2018 09:35, Cecil Westerhof wrote:
> But I would prefer not to. One reason: the parameters will change.
Those are *good* instincts! Others have told you what's wrong; I'm just
building on what they've said.
One thing I often like to do where I've got a fairly complex command
being called from Tcl is to make a little procedure that wraps it to
handle the actual calling, any packing of arguments, and ensuring that
the output is parsed correctly. (In some cases, you need to use some
non-obvious redirects to make things work, or tricky shell
intermediates. That's pretty horrible, and a great reason for hiding the
details.) In this case, it might be as simple as:
proc pip args {
global pip
exec $pip {*}$args
}
while {[catch {set output [pip {*}$parameters]} errStr opts]} {
....
}
Or you might push more smartness into the procedure. (For example, some
commands _insist_ on exiting with non-zero result codes even for trivial
issues, and you have to filter such things out and do special tricks to
get the output from them in such cases.)
Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.