Skip to content
narugit edited this page Sep 23, 2021 · 1 revision

Welcome to the dotfiles wiki!

shell script 詰まったところ

  • 連想配列(declare -A)が使えるのは、bash ver. 5から。
  • 関数から配列を返すには、declare -nを使う方法があるが、この記法はver. 4.3から。関数からは文字列で返して、受け取り側で配列化する。
get_array_like_string() {
  hoge=("a" "b")
  echo {$hoge[@]}
}

arr=($(get_array_like_string))

Clone this wiki locally