I like the idea but haven't run-tested it yet. Some comments inline.

On Fri, Mar 02, 2018 at 05:04:49PM -0700, Aaron Bieber wrote:
> +# Return disk devices along with their uids.
> +scan_disks() {
> +     local IFS=, _disks=$(sysctl -n hw.disknames)
> +
> +     bsort $_disks
> +}
You can inline the subshell as already done in other places.

> +# Determine the disk name from supplied disk uid.
> +duid_to_disk() {
> +     local _in=$1 _disk
_disk is unused.

> +     local _disks=$(scan_disks)
> +
> +     for _d in ${_disks}; do
> +             local _a=${_d##*:}
> +             local _b=${_d%%:*}
> +             if [[ $_in == ${_a} ]]; then
One with and one without {} seems odd.

> +                     echo $_b
> +                     return
> +             fi
> +     done
> +
> +     echo $_in
> +}
_disks, _a and _b can be inlined. None if them is used more than once
after assignment and according to your logic _b might be assigned but
not used at all.

I've seen disks without UUIDs in hw.disknames, did you consider this?
Looks like _b would be empty in that case.

Reply via email to