In Solaris, basename(1) and basename(3) both return `"."` while given an empty
string (`""`), while in BSD (and Linux) basename(1) returns "" and basename(3)
returns `"."`
This patch accepts basename() in D script returns `""` or `"."`
While here, also:
- change `#!/usr/bin/ksh` to `#!/usr/bin/env ksh` to find `ksh` in `$PATH`
- fix a quotation inconsistency in `dirname` part