[rundir] make it work in dash; fixed a bug that didn't show itself in bash