exit command

Jan Weitzel J.Weitzel at phytec.de
Thu Mar 4 09:38:51 EST 2010


Hello
I am trying to fix a problem with the return value coming from exit within 
a if statement.
This test shows the problem:

barebox:/ cat ./tif 
if [ 1 -ne 0 ]; then
 echo in if
 exit 1
fi
barebox:/ ./tif
in if
barebox:/ echo $?
0

In common/hush.c run_list_real(struct pipe *pi) calls run_pipe_real(struct 
pipe *pi).
In function run_pipe_real(struct pipe *pi) line 540 a child pipe is 
started. This child pipe works fine and set a prober last_return_code. 
After return from run_list_real(struct pipe *pi) the return value -2 (Line 
702) is given from run_pipe_real(struct pipe *pi) to run_list_real(struct 
pipe *pi)  and here the right last_return_code will be overwritten.

exit is a command only modifying the wanted exit value r with "return -r - 
2". So here we have also -2 or -3 as return value.
Is the problem located in the line 700 "if (rcode < -1)" statement, or 
should exit be a reserved word to controls the flags? I am not sure why we 
need the father pipe.

Kind Regards
Dipl. Ing. (FH) Jan Weitzel

-Software Entwicklung-
PHYTEC Messtechnik GmbH
Robert-Koch-Str. 39
55129 Mainz
Tel.: +49 (0)6131 9221-0
Web: http://www.phytec.de

Geschäftsführer: Dipl.-Ing. Michael Mitezki, Handelsregister Mainz, HRB 
4656, Finanzamt Mainz-Mitte, St.Nr. 266500608, DE 149059855
This E-Mail may contain confidential or privileged information. If you are 
not the intended recipient (or have received this E-Mail in error) please 
notify the sender immediately and destroy this E-Mail. Any unauthorized
copying, disclosure or distribution of the material in this E-Mail is 
strictly forbidden.



More information about the barebox mailing list