perl - Propagate exit status across pipes -


I would like to use a small script to do some cosmetic work in the production of my GCC.

So I use this command:

  mygcc foo.c 2> And 1. Myscript.pl  

Actually my script works like this:

  $ error = 0; While (<>  

Unfortunately, the exit code from the GCC is not properly spread through the pipe. What I have to do, get the exit code from GCC and write it back with my script

Without it, the construction process can not be stopped properly in case of error.

How can I get it?

Try to use a sub-shell:

  (Mygcc foo.c; "GCC returns $?"?). & Amp; Myscript.pl  

(cmd) is created to launch cmd in a sub-shell, your current shell The decoy itself will be done, and the commands will be executed by the hair follicle. This is an easy way to run many commands and output to a pipe has been given.

$? The variable is the exhaust position of the last command.

cmd1 | & Amp; Cmd1 build cmd1 2> And 1. Cmd2


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -