Subject: More Solaris shell bugs
To: grant beattie <grant@NetBSD.org>
From: Roland Illig <rillig@NetBSD.org>
List: tech-pkg
Date: 08/23/2005 10:06:34
In mk/install/bsd.pkginstall.mk, the following occurred:

rm -f /tmp/obj/www/apache/work/.install-perms.tmp
set -x;
test -f /tmp/obj/www/apache/work/.install-perms.tmp || \
{
   case "" in
     "") ;;
     *) /usr/bin/touch -f /tmp/obj/www/apache/work/.install-perms.tmp;;
   esac
}
+ test -f /tmp/obj/www/apache/work/.install-perms.tmp
*** Error code 1

Stop.
bmake: stopped in /usr/pkgsrc/www/apache

The unforeseen behavior here is that the { case ... esac; } block does 
not reset the error flag which had been set by the test(1) command. So 
after executing the block, it is still 1, and the shell exits.

There are (at least) three possible work-arounds:

1. Use "if ... fi" instead of "||" and "&&".
    The "if" command does not affect the error flag.

2. Use "(...)" instead of "{...;}".
    The subshell does affect the error flag.

3. Insert ${TRUE} or ${DO_NADA} somewhere in the "{...}" block.

Roland