The problem with this line:
eval exec [linsert $args 0 exec] >> $tempFile &
is multi-fold. Firstly, you've got a double exec
(unlikely to be what you want!). Secondly, you've got a piece at the end which isn't being list protected despite running on a platform that quite often has spaces in filenames, making the filename be a bit of a timebomb waiting to go off (though I think it's not as bad on Windows 7 as it was on older versions, where common writable locations had spaces in the filename).
Now, if you were using a supported version of Tcl then we'd recommend writing that as:
exec {*}$args >> $tempFile &
(Indeed, this sort of thing was one of the key use-cases for the {*}
syntax.)
However, you're on an ancient version so we have to do things the other way. It still helps that we've got the above as it guides where we need to insert non-list arguments in the overall list:
eval [linsert [linsert $args 0 exec] end >> $tempFile &]
Yes, this is hard to read and error-prone to write. Why do you think we literally changed the base language to put in something to address that? (Hardly anyone uses eval
directly any more, and that's greatly reduced the defect rate in most folks' code.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…