build: try to get dash/bash for sanity

The "local" builtin is not part of POSIX.  We want it.  Try harder to
get a vaguely sane shell, rather than just a POSIX shell.

Also, safeguard to error out more gracefully if invoked from outside the
build process.