working on issue #4
Also, distinguish between script name and binary name (#4)
Thanks to @timeos for the initial version (#4)