Hopefully Someone Will Check and Comment on My Logic [OT Maybe?]

Dan McGhee beesnees62 at att.net
Sun Mar 13 13:48:35 PDT 2011

On 03/12/2011 06:00 PM, Dan McGhee wrote:
> One thing I want it to do is recover from a failed 'make' or 'install' 
> without have to run the whole script again.  This feature *used to* 
> work.  It now doesn't.  If everything is OK, the script runs from the 
> beginning to the successful end of a build.  But if there is a 
> "glitch," the recovery doesn't happen.
I'm replying to my own original post.  Needed to have some stuff that 
the others "snipped" to show the error of my ways.  The script was doing 
exactly what I told it to do.  There were no problems with variables, 
syntax or exit status.

What I didn't put in my original post, and this is my personal logic 
error, is that when I exited the script after "make," simulating a 
failed "install," it started at "make" again and not "install."  Please 
look at the following sequence.
> # This one recovers from failed "make."
> if [ -e $logdir/make-`echo $package`.err ] && \
> [ ! -e $logdir/install-`echo $package`.err ]; then
> # This one recovers from a failed install
> if [ -e $logdir/make-`echo $package`.log ] && \
> [ ! -e $HOME/$package-files.list ]; then
> # This one does everything through configure, make, make install
> if [ ! -e $logdir ];  then
The order is failed make, failed install and fresh build.  If the 
"install" fails after "make," the conditions exist to "make,"and the 
script will start there.  So the order of the first two tests needed to 
be reversed.  I did that and everything works the way I want it to.

Thanks, Aleksandar and Neal, for your inputs.  My syntax is now more 
elegant in addition to working.  I learned a "trick" from the Advanced 
Bash Scripting Guide that proved to me that everything was as it should 
be except what I wanted the script to do.

I had inspected and made sure that all the files and directories existed 
and had the right names.  They did.  But that didn't mean that the tests 
were parsing everything correctly, so I wanted to do something to test 
the test.  I stumbled on this which is exactly what I needed:

if [ -e $file ]; then
      echo "$file exists"
      echo "$file does not exist"

Inserting two loops like this to check my tests is what lead me to 
realize that the test order was not correct.

Once again, thanks for the responses.  I learned quite a bit.


More information about the lfs-support mailing list