This was requested in #32573 (comment), as it is currently not possible to catch this type of error in a Bash linter (https://github.com/bitcoin/bitcoin/pull/32573#pullrequestreview-2857077463). Also, reviewers are not familiar with it and didn’t catch the above bug either. (Thus, it is discouraged in the dev notes: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#scripts)
So just use a simple python script.