LFS-svn chap 6.7 (gcc: No such file or directory)

Neal Murphy neal.p.murphy at alum.wpi.edu
Wed Sep 8 12:02:31 PDT 2010


On Wednesday 08 September 2010 05:56:23 Martin Zajíc wrote:
> I have another question about testing error.
> I try to make LOG with '{....} 2>&1 | tee $BUILD_DIR/LOG_$PROGRAM.log'
> but when I did it how can I test it for errors, becouse '$?' not
> working even if the script inside ending with 'exit 1'.

echo "Building section fubar"
(
   echo "  command" > /dev/tty
   command || (echo "command failed! exit 1)
   echo "  command" > /dev/tty
   command || (echo "command failed! exit 1)
   echo "  command" > /dev/tty
   command || (echo "command failed! exit 1)
   echo "  command" > /dev/tty
   command || (echo "command failed! exit 1)
) > "$BUILD_DIR/LOG_$PROGRAM.log" 2>&1

Run it. You'll see 'tidy' progress. If you want to see the gory details, 
run 'tail -f -s .1 "$BUILD_DIR/LOG_$PROGRAM.log"' in another window.

Oh, wait. I think I know the problem. You are using {} (curly braces) around 
the code block instead of () (parens). They behave differently.  Your script 
is properly exitting from the {} environment, which is different from your 
script's environment. Use parens; I think they'll do what you want.



More information about the lfs-support mailing list