Makefile执行步骤在终端上不会打印,如果文件是从一个tcl文件执行的。

huangapple go评论63阅读模式
英文:

Makefile execution steps does not print in terminal if file is executed from a tcl file

问题

proc buildMirus { } {
exec ./autogrn.sh
if { [catch { exec make -j 6 }] } { /* make should give execution steps on terminal but it's not happening*/
puts "Error occurred while building"
}
}

英文:
proc buildMirus { } {
    exec ./autogrn.sh
    if { [catch { exec make -j 6 }] } { /* make should give execution steps on terminal but it's not happening*/
        puts "Error occured while building"
       }
   }

答案1

得分: 2

Tcl的exec命令默认将子进程的stdout用作exec的正常结果,并将子进程的stderr用作exec抛出的错误消息(如果存在)。这对许多用途非常方便,但不适用于您在这里的需求,您希望将输入和输出直接传递给用户,只处理任何错误代码。您可以通过添加一些重定向来实现这一点,具体如下:

if { [catch { exec make -j 6 <@stdin >@stdout 2>@stderr }] } {

<@stdin表示“从stdin通道获取输入”,>@stdout表示“将正常输出发送到stdout通道”,2>@stderr表示“将错误输出发送到stderr通道”。

英文:

Tcl's exec command defaults to consuming the stdout of the subprocess to be the normal result of the exec, and to consuming the stderr of the subprocess to be the message of an error thrown by exec (if it exists). This is very convenient for many uses, but not what you want here, where you want to let the input and output go directly from/to the user and just handle any error codes. You can do this by adding some redirects, specifically:

if { [catch { exec make -j 6 &lt;@stdin &gt;@stdout 2&gt;@stderr }] } {

&lt;@stdin says "take input from the stdin channel", &gt;@stdout says "send normal output to the stdout channel", and 2&gt;@stderr says "send error output to the stderr channel".

huangapple
  • 本文由 发表于 2023年3月15日 20:30:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75744713.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定