1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-22 04:45:11 +00:00

Use improved _join().

This commit is contained in:
William Melody 2020-06-07 13:25:03 -07:00
parent 4aeab14d2d
commit f0ebb08cd4

20
hosts
View File

@ -323,19 +323,21 @@ _contains() {
# _join() # _join()
# #
# Usage: # Usage:
# _join <separator> <array> # _join "," a b c
# _join "${an_array[@]}"
# #
# Examples: # Returns:
# _join , a "b c" d => a,b c,d # The list or array of items joined into a string with elements divided by
# _join / var local tmp => var/local/tmp # the optional separator if one is provided.
# _join , "${FOO[@]}" => a,b,c
# #
# More Information: # More information:
# http://stackoverflow.com/a/17841619 # https://stackoverflow.com/a/17841619
_join() { _join() {
local IFS="${1}" local _delimiter="${1}"
shift shift
printf "%s\\n" "${*}" printf "%s" "${1}"
shift
printf "%s" "${@/#/${_delimiter}}" | tr -d '[:space:]'
} }
# _blank() # _blank()