Also change the logic a bit to iterate over the individual files per
directory, as having a directory without bash commands will otherwise
pass a literal `*.sh` to `bash -n`, causing it to fail.
ClosesHomebrew/homebrew#48323.
Signed-off-by: Martin Afanasjew <martin@afanasjew.de>