Use getopts to parse script options

getopts is POSIX compliant and surprisingly portable; even SVR4
supports it.
Simplify "prefixes" join; avoid sed call.
A few tests for script options.