Date: Fri, 15 Aug 2014 03:05:41 +0000 From: Cary <cary@SDF.ORG> To: Warren Block <wblock@wonkity.com>, Rick Miller <vmiller@hostileadmin.com>, FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: /bin/sh script not behaving as expected Message-ID: <20140815030541.GA20578@SDF.ORG> In-Reply-To: <20140815015559.GA21249@SDF.ORG> References: <CAHzLAVE1E8hZvZEnDko8-7cfx6JYypezi3oxs4vKKjxDzSzZnw@mail.gmail.com> <alpine.BSF.2.11.1408141143010.53473@wonkity.com> <20140815015559.GA21249@SDF.ORG>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Aug 15, 2014 at 01:55:59AM +0000, Cary wrote:
> > On Thu, 14 Aug 2014, Rick Miller wrote:
> >
> > >Hi all,
> > >
> > >#! /bin/sh
> > >
> > >disks="da2 da1 da0";
> > >
> > >for d in ${disks}; do
> > > if [ -z "${disk}" -o "${disk}" '>' "${d}" ]; then
> > > : ${disk:=${d}};
> > > fi
> > >done
> >
> > The algorithm is not clear to me,
>
> Nor me.
> Rick, I don't understand the test. Would just
>
> if [ -z "${disk}" ]; then
>
> suffice ? Single-quoting the > operator looks like an error that would have
> prevented the shell from executing the script.
Ok, it is possible.
You can see that with or without quotes around the comparison operator
the test is the same.
$ if [ foo != bas ] ; then echo bar;fi
bar
$ if [ foo '!=' bas ] ; then echo bar;fi
bar
> > or, more correctly,
> >
> > disk=`sysctl -n kern.disks | tr " " "\n" | sort | head -n1`
> > _______________________________________________
--
cary@sdf.org
SDF Public Access UNIX System - http://sdf.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140815030541.GA20578>
