mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-25 22:27:42 +00:00
Use improved _join()
.
This commit is contained in:
parent
4aeab14d2d
commit
f0ebb08cd4
20
hosts
20
hosts
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user