On 9/11/18 4:06 PM, Richard W.M. Jones wrote:

+        "
+plugins="$(echo $lang_plugins $non_lang_plugins | xargs -n1 | sort -u | xargs)"

Your use of xargs as a reformatter is interesting ;) Could also be spelled:

$(echo $lang_plugins $non_lang_plugins | tr -s ' \t\n' ' ' | sort -u
| tr ' ' '\n')"

but that's longer to type, so your version is fine.

This one actually came from stackoverflow:

   https://stackoverflow.com/a/8802788

which also mentioned:

plugins=$(echo $(printf %s\\n $lang_plugins $non_lang_plugins | sort -u))

for less typing, fewer processes, and no dependence on xargs.

Isn't shell golf fun :)


I wanted something that would work on BSD (although I didn't test it
yet ...)

I haven't tested on BSD either, but all of the solutions listed here [whether xargs, tr, or $echo $(printf %s\\n)] are portable at least according to POSIX.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to