Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Aug 2014 11:49:12 -0300 (ADT)
From:      Andrew Hamilton-Wright <AHamiltonWright@MtA.ca>
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.1408141145540.1133@qemg.org>
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:

   [ ... condensed ... ]

> for d in ${disks}; do
>   if [ -z "${disk}" -o "${disk}" '>' "${d}" ]; then
>      : ${disk:=${d}};
>   fi
> done

   [ ... condensed ... ]

> # $disk; If $disk is unset/null, $disk is set to $d.  If $disk is set, it
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I believe that this is your problem -- you want to update the value
of disk whenever your if statement is true, whereas the above will
do so only when the if statement is true _and_ your variable is unset.

Is there a reason you are not simply using:
   disk=${d}
as the assignment in your if statement?

Andrew.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.11.1408141145540.1133>