Date: Thu, 14 Aug 2014 11:51:53 -0600 (MDT) From: Warren Block <wblock@wonkity.com> To: Rick Miller <vmiller@hostileadmin.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: /bin/sh script not behaving as expected Message-ID: <alpine.BSF.2.11.1408141143010.53473@wonkity.com> In-Reply-To: <CAHzLAVE1E8hZvZEnDko8-7cfx6JYypezi3oxs4vKKjxDzSzZnw@mail.gmail.com> References: <CAHzLAVE1E8hZvZEnDko8-7cfx6JYypezi3oxs4vKKjxDzSzZnw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 14 Aug 2014, Rick Miller wrote: > Hi all, > > I have shell code whose purpose is to determine the first disk in the > system where FreeBSD is to be installed. The code is not behaving as > expected and I?m hoping that fresh pairs of eyes might help me identify the > problem. > > Here is the script along with an explanation of the implementation and > description of the problem: > > #! /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, but I would do something simpler like disk=`cd /dev; ls da? | head -n1` or, more correctly, disk=`sysctl -n kern.disks | tr " " "\n" | sort | head -n1`
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.11.1408141143010.53473>