« Back to Index

[Bash function passed an Array]

View original Gist on GitHub

Tags: #bash #array

Bash function passed an Array.sh

#!/bin/bash

function accept {
  local things=("${!1}")

  for thing in "${things[@]}"
  do
    echo "thing: $thing"
  done
}

things=(foo bar baz)

accept things[@]