1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00

makefiles: Reject 2>&1 > /dev/null

While this could theoretically be desired, it's usually just a mishap.
It is unlikely that legitimate cases will be needed in the build system;
if so, they can exclude themselves.

See-Also: https://github.com/RIOT-OS/RIOT/pull/16775
This commit is contained in:
chrysn 2021-08-24 17:50:11 +02:00
parent 6bcc68b9cc
commit 1c6b675d9f

View File

@ -347,6 +347,19 @@ check_shell_which() {
| error_with_message "Don't use \`which\` in makefiles, use \`command -v\` instead."
}
check_stderr_null() {
local patterns=()
local pathspec=()
patterns+=(-e '2>[[:blank:]]*&1[[:blank:]]*>[[:blank:]]*/dev/null')
pathspec+=('Makefile*')
pathspec+=('**/Makefile*')
pathspec+=('**/*.mk')
git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message "Redirecting stderr and stdout to /dev/null is \`>/dev/null 2>&1\`; the other way round puts the old stderr to the new stdout."
}
error_on_input() {
! grep ''
}
@ -367,6 +380,7 @@ all_checks() {
check_no_usemodules_in_makefile_include
check_no_pkg_source_local
check_shell_which
check_stderr_null
}
main() {