$0 seems to work well but executing variables makes me a bit iffy as always. realpath is not a part of the standard Debian distribution and I saw no gain in having it so I left it out. But the flexibility should be positive so I committed a fix with this in it.