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

Neal Murphy neal.p.murphy at alum.wpi.edu
Sat Mar 12 18:00:28 PST 2011


On Saturday 12 March 2011 19:00:56 Dan McGhee wrote:
> # This one recovers from failed "make."
> if [ -e $logdir/make-`echo $package`.err ] && \
> [ ! -e $logdir/install-`echo $package`.err ]; then      #Now build
> 
> <removed "make," "make check" and "make install" sections>
> fi
> 
> # This one recovers from a failed install
> if [ -e $logdir/make-`echo $package`.log ] && \
> [ ! -e $HOME/$package-files.list ]; then

Technically, you may be mixing metaphors with this syntax. Perhaps the syntax 
is valid, but it isn't doing what you expect. Try:
  if [ -e "file_1" -a ! -e "file_2" ]; then
    <commands>
  fi
  # equivalent: if test -e "$file_1 -a ! -e file_2; then

OR use:
  [ -e "file_1" ] && [ ! -e "file_2" ] && {
    <commands>;
  }
  # equivalent: test -e "$file_1 && test ! -e file_2 && {

OR even use:
  [ -e "file_1" -a ! -e "file_2" ] && {
    <commands>;
  }
  # equivalent: test -e "file_1" -a ! -e "file_2" && {

Also, the syntax '-e "$logdir/make-${package}.log"' will eliminate a smidgeon 
of complexity even though what you did is correct. Any time you aren't sure if 
a shell var like $var will be, or is being, parsed correctly in context, put 
the name in braces, as in ${var}.

Nothing else on your script pokes me in the eye with a sharp stick.



More information about the lfs-support mailing list