aboutsummaryrefslogtreecommitdiff
path: root/lib/20-strings
diff options
context:
space:
mode:
Diffstat (limited to 'lib/20-strings')
-rw-r--r--lib/20-strings14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/20-strings b/lib/20-strings
new file mode 100644
index 0000000..f04f68d
--- /dev/null
+++ b/lib/20-strings
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+join(){
+ # Join strings by a given delimiter.
+ # $1 = delimiter
+ # $2..$N = strings
+ _bcj_delim=$1; shift
+ _bcj_result=''
+ while [ $# -gt 0 ]; do
+ _bcj_result="${_bcj_result:+${_bcj_result}${_bcj_delim}}${1}"
+ shift
+ done
+ printf '%s' "$_bcj_result"
+}