> > This looks weird:
> > 
> >     gate5b# rcctl ls failed
> >     smtpd
> >     gate5b# x=$(rcctl ls failed) && rcctl restart $x
> >     gate5b# rcctl ls failed
> >     smtpd
> >     gate5b# echo $?
> >     1
> > WTH?

I believe this may have been written with the intention of "if the
variable x contains any value, then there must be something failed",
but then it uses regular shell job control with && , which relies on
exit values returned from the task, in this case rcctl and its
parameters (ls failed)

because "rcctl ls failed" returns a 1 if something has failed, "&& rcctl
restart ..." is never executed.

I believe this may have been what was intended:
x=$( rcctl ls failed ); [ -n "$x" ] && rcctl restart $x

Reply via email to