After some experimenting I believe that I've discovered how to fix the
problem, and the reason for it - I'd been thinking of the '&&' shortcut
as functionally identical to the if-then-fi construct.  That's obviously
(now ;) not the case.  If, as in the previous message, the following
'&&' shortcut is used:

#v+
[ -z "$RB_TEMP" ] && PKGLIST="$PKGLIST $PKG"
#v-

Then, if RB_TEMP is not of zero length, the exit status of that command
is one.  Since that command is the last performed in the
list_required_by function, the exit status of the function is one.
Because I used 'set -e' at the top of the script, any command (a
function being a complex command) that exits with a value of one halts
the execution of the script.  However, if we change that line to:

#v+
if [ -z "$RB_TEMP" ] ; then
        PKGLIST="$PKGLIST $PKG"
fi
#v-

Then, following the fi, the exit status is zero for both the command and
the function, and all following commands are executed.  The following
also works:

#v+
[ ! -z "$RB_TEMP" ] || PKGLIST="$PKGLIST $PKG"
#v-

Because the exit status of the first command on the line is zero if
RB_TEMP is not zero length.

So, there's a fix for it.  Figured I'd post this FTR, just in case
someone else has a lack of brain bytes similar to mine. ;]

Regards,
-- 
dave [ please don't CC me ]
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to