Fix the build with debug enabled and remove a variable used only at switch
initialization, it is nonsense keep it around without futher use.
sh: Add more necessary INTOFF/INTON.
sh: Send getopts error messages to stderr, not stdout.

Adjust a testcase for this change.