Use `dirname` to set the current directory

`readlink` is a completely different command on BSD and, switches aside,
prints nothing if you run it on anything that isn't a symlink.