Simulating hash tables in bash

On my previous blog (which I did not migrate), I posted this snippet to simulate hash tables in bash. Is it useful? Maybe. In any case, this is an slightly improved version which allows ‘values’ to have spaces in them. Apparently (I’ve never tested it before today), this was kind of a problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
hash_table=(
    key1='value1'
    key2='value2'
)
 
hash_get() {
    local _table="$1";
    local _key="$2";
    local _value="${_table}[@]";
    local "${!_value}";
    eval echo "\$${_key}";
}
 
hash_get "hash_table" "key2";

Hello world!

My new wordpress installation! I have yet to figure out wether or not to import my old blog entries. I don’t feel much like it for now, but I might change my mind later. For now, it’s going to be empty! (unless I feel like blogging).

Some info on the setup? I’m using wordpress svn with some git-svn magic to keep my code in version control. Using git-svn also solved my biggest hastle I used to have that I couldn’t easily mix a wordpress installation in my document root with existing files and/or folders (error pages, some stats folder, various other thingies).

The wordpress plugins I use are also managed in git, but not with git-svn. I’m unsure if its possible to use git-svn with git-submodules. And even if it is, it may be too much of a command mess to update them all. Instead, I’ll just write a little script I can run whenever wordpress complains about updating plugins that will loop over them and run a svn update (with a git commit with a nicely predefined commit message.

Code will follow!