INNER CODE UNIT · Shell

array_join

gruntwork-io/bash-commons · modules/bash-commons/src/array.sh:48

function array_join {
  local -r separator="$1"
  shift
  local -ar values=("$@")

  local out=""
  for (( i=0; i<"${#values[@]}"; i++ )); do
    if [[ "$i" -gt 0 ]]; then
      out="${out}${separator}"
    fi
    out="${out}${values[i]}"
  done

  echo -n "$out"
}

# Adds the given $prefix to the beginning of each string element in the given $array
#

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…