Fix bashisms and shebangs in scripts

Fix bashisms in some shell scripts.
Fix shebang in scripts that contains bash-specific constructions.