On Tue, Sep 06, 2022 at 05:50:31PM +0000, Lucas wrote:
> Klemens Nanni <[email protected]> wrote:
> > Yes I want it to fail, just like reorder_kernel.sh using `set -o errexit'
> > does with
> > [ -f /etc/bsd.re-config ] && config -e -c /etc/bsd.re-config -f bsd
> >
> > If the config file exists but is invalid, I expect programs using it to
> > fail.
>
> Sorry for the noise. I wasn't aware that `set -e` only takes into
> consideration the last command in an AND-OR list and not the exit status
> of the AND-OR list itself.
What is the status of the list itself?
A && B
returns the exit code of A if it is non-zero or the exit code of B if
A exited non-zero.
>
> > install -F -m 700 bsd.rd /bsd.upgrade
> > +if [ -f /etc/bsd.re-config ] &&
> > + config -e -c /etc/bsd.re-config -f /bsd.upgrade >/dev/null
> > logger -t sysupgrade -p kern.info "installed new /bsd.upgrade. Old kernel
> > version: $(sysctl -n kern.version)"
>
> Nevertheless, the thing that prompted me to reply was that the current
> patch reads `if cmd && something`. It should either what I replied, or
> the leading `if` should be dropped.
Oh dear... these mistakes slip in if you test a diff on one machine and
reconstruct it on another rather than copying over a patch file.
Thanks for pointing it out, here's the correct diff.
Index: sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.48
diff -u -p -r1.48 sysupgrade.sh
--- sysupgrade.sh 8 Jun 2022 09:03:11 -0000 1.48
+++ sysupgrade.sh 6 Sep 2022 17:58:03 -0000
@@ -208,6 +208,8 @@ fi
VNAME="${_NEXTKERNV[0]}" fw_update -p ${FW_URL} || true
install -F -m 700 bsd.rd /bsd.upgrade
+[ -f /etc/bsd.re-config ] &&
+ config -e -c /etc/bsd.re-config -f /bsd.upgrade >/dev/null
logger -t sysupgrade -p kern.info "installed new /bsd.upgrade. Old kernel
version: $(sysctl -n kern.version)"
sync