Skip to content

Instantly share code, notes, and snippets.

@akesterson
Created November 1, 2013 17:24
Show Gist options
  • Select an option

  • Save akesterson/7268778 to your computer and use it in GitHub Desktop.

Select an option

Save akesterson/7268778 to your computer and use it in GitHub Desktop.
akesterson@ATLPTLBS3TWW1 ~/source/vocalocity/tools-orchestration
$ cat ~/tmp/test.sh
#!/bin/bash
declare -A hashvar
declare -a array
function useit
{
hashvar['lolsomething']=lol
hashvar['lolwtf']=wtf
array[0]=lol
array[2]=yar
}
function clearit
{
for arr in hashvar array
do
unset $arr[*]
done
hashvar=()
array=()
}
useit
echo "hashvar : ${!hashvar[@]} : ${hashvar[@]}"
echo "array : ${!array[@]} : ${array[@]}"
clearit
useit
echo "hashvar : ${!hashvar[@]} : ${hashvar[@]}"
echo "array : ${!array[@]} : ${array[@]}"
akesterson@ATLPTLBS3TWW1 ~/source/vocalocity/tools-orchestration
$ bash ~/tmp/test.sh
hashvar : lolsomething lolwtf : lol wtf
array : 0 2 : lol yar
hashvar : 0 : wtf
array : 0 2 : lol yar
akesterson@ATLPTLBS3TWW1 ~/source/vocalocity/tools-orchestration
$ bash --version
GNU bash, version 4.1.10(4)-release (i686-pc-cygwin)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment