Expand ~ character in paths

This should resolve #9. This does not rely on the shell to expand paths,
only on POSIX commands.