Added 'join' function

This commit is contained in:
Nathaniel Landau
2016-01-10 19:44:21 -05:00
parent bc02ca013f
commit 3ac9eb30bd

View File

@@ -3,12 +3,13 @@
# ################################################## # ##################################################
# Shared bash functions used by my bash scripts. # Shared bash functions used by my bash scripts.
# #
# VERSION 1.0.0 # VERSION 1.3.0
# #
# HISTORY # HISTORY
# #
# * 2015-01-02 - v1.0.0 - First Creation # * 2015-01-02 - v1.0.0 - First Creation
# * 2015-04-16 - v1.2.0 - Added 'checkDependencies' and 'pauseScript' # * 2015-04-16 - v1.2.0 - Added 'checkDependencies' and 'pauseScript'
# * 2016-01-10 - v1.3.0 - Added 'join' function
# #
# ################################################## # ##################################################
@@ -114,6 +115,18 @@ function pushover() {
fi fi
} }
# Join
# ----------------------------------------------
# This function joins items together with a user specified separator
# Taken whole cloth from: http://stackoverflow.com/questions/1527049/bash-join-elements-of-an-array
#
# Usage:
# join , a "b c" d #a,b c,d
# join / var local tmp #var/local/tmp
# join , "${FOO[@]}" #a,b,c
# ----------------------------------------------
function join { local IFS="${1}"; shift; echo "${*}"; }
# File Checks # File Checks
# ------------------------------------------------------ # ------------------------------------------------------
# A series of functions which make checks against the filesystem. For # A series of functions which make checks against the filesystem. For