mirror of
https://github.com/octoleo/hosts.git
synced 2025-02-06 20:38:26 +00:00
Use updated _join()
implementation.
Source: https://github.com/alphabetum/bash-boilerplate
This commit is contained in:
parent
dd25af8c99
commit
661fa3b114
24
hosts
24
hosts
@ -439,21 +439,19 @@ _contains() {
|
|||||||
# _join()
|
# _join()
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# _join "," a b c
|
# _join <separator> <array>
|
||||||
# _join "${an_array[@]}"
|
|
||||||
#
|
#
|
||||||
# Takes a separator and a list of items, joining that list of items with the
|
# Examples:
|
||||||
# separator.
|
# _join , a "b c" d => a,b c,d
|
||||||
|
# _join / var local tmp => var/local/tmp
|
||||||
|
# _join , "${FOO[@]}" => a,b,c
|
||||||
|
#
|
||||||
|
# More Information:
|
||||||
|
# http://stackoverflow.com/a/17841619
|
||||||
_join() {
|
_join() {
|
||||||
local separator
|
local IFS="${1}"
|
||||||
local target_array
|
shift
|
||||||
local dirty
|
printf "%s\\n" "${*}"
|
||||||
local clean
|
|
||||||
separator="${1}"
|
|
||||||
target_array=(${@:2})
|
|
||||||
dirty="$(printf "${separator}%s" "${target_array[@]}")"
|
|
||||||
clean="${dirty:${#separator}}"
|
|
||||||
printf "%s" "${clean}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# _command_argv_includes()
|
# _command_argv_includes()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user