/bin/sh script not behaving as expected

Andrew Hamilton-Wright AHamiltonWright at MtA.ca
Thu Aug 14 14:49:22 UTC 2014

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:
as the assignment in your if statement?


More information about the freebsd-questions mailing list