Follow-up to #55785.
In `black_format.sh`, the `--exclude` switch was wrongly used. It's a misnomer
that only excludes _untracked_ files, arcane pathspec patterns should instead
be used to exclude _tracked_ files.
Using this newfound knowledge, we can also simplify the other scripts.
It's too hard to get compatibility between GNU and BSD sed,
so let's just use perl oneliners.
And improve it to also remove trailing tabs, not just spaces.