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()
|
||||
#
|
||||
# Usage:
|
||||
# _join "," a b c
|
||||
# _join "${an_array[@]}"
|
||||
# _join <separator> <array>
|
||||
#
|
||||
# Takes a separator and a list of items, joining that list of items with the
|
||||
# separator.
|
||||
# Examples:
|
||||
# _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() {
|
||||
local separator
|
||||
local target_array
|
||||
local dirty
|
||||
local clean
|
||||
separator="${1}"
|
||||
target_array=(${@:2})
|
||||
dirty="$(printf "${separator}%s" "${target_array[@]}")"
|
||||
clean="${dirty:${#separator}}"
|
||||
printf "%s" "${clean}"
|
||||
local IFS="${1}"
|
||||
shift
|
||||
printf "%s\\n" "${*}"
|
||||
}
|
||||
|
||||
# _command_argv_includes()
|
||||
|
Loading…
x
Reference in New Issue
Block a user