-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
makefiles: Sort >/dev/null and 2>&1 #16775
Conversation
Redirecting `2>&1 >/dev/null` moves stderr to stdout first and then stdout to /dev/null; when checking for command existence or otherwise silencing output, this is usually not desired (but only starts producing errors when the actual command fails, which is often not tested).
I've set this to skip the compile tests, based on this only affecting tool detection lines; reviewers please remove that flag if you disagree. |
Might this be an issue for other versions onf |
Regarding testing, the behaviour is still the same but I'm using the debianutils version of which... |
I held off on replacing with Having found it used in the makefiles since, I'm putting the later changes on top of this. |
@@ -327,12 +327,12 @@ APPLICATION := $(strip $(APPLICATION)) | |||
|
|||
ifeq (,$(and $(DOWNLOAD_TO_STDOUT),$(DOWNLOAD_TO_FILE))) | |||
ifeq (,$(WGET)) | |||
ifeq (0,$(shell which wget 2>&1 > /dev/null ; echo $$?)) | |||
ifeq (0,$(shell which wget > /dev/null 2>&1 ; echo $$?)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it even necessary to redirect stderr to stdout at this point? It will be printed either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying for minimal changes here; as that's apparently not called for (cf. #16775 (comment)), the latest additions do away with this.
As in "it still fails" or in "it didn't fail before"? Which command were you testing with? (My current go-to is |
Seems my worries were warranted -- one of the build environments doesn't even know No clue why (the python-tests job of .github/workflows/tools-test.yml is supposed to be run on ubuntu-latest whose shells do know command), but I'll revert this to only being the first commit which is minimally fixing things, and see to the rest in a follow-up. |
c7cfc50
to
648e014
Compare
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: RIOT-OS#16775
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, small enough change. Locally behaviour is the same.
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: RIOT-OS#16775
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: RIOT-OS#16775
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: RIOT-OS#16775
This is a follow-up for [16775], and was not caught there as that search was limited to `which`. Note that while this line can be simplified, the redirects ensure that GNU Make < 4.3 will not optimize it into its own built-in shell that does not know `command`. [16775]: RIOT-OS#16775
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: RIOT-OS#16775
This is a follow-up for [16775], and was not caught there as that search was limited to `which`. Note that while this line can be simplified, the redirects ensure that GNU Make < 4.3 will not optimize it into its own built-in shell that does not know `command`. [16775]: RIOT-OS#16775
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: RIOT-OS#16775
This is a follow-up for [16775], and was not caught there as that search was limited to `which`. Note that while this line can be simplified, the redirects ensure that GNU Make < 4.3 will not optimize it into its own built-in shell that does not know `command`. [16775]: RIOT-OS#16775
Contribution description
Redirecting
2>&1 >/dev/null
moves stderr to stdout first and thenstdout to /dev/null; when checking for command existence or otherwise
silencing output, this is usually not desired (but only starts producing
errors when the actual command fails, which is often not tested).
In particular cases, the redirect made things even worse: while stderr would have gone to the user's screen otherwise, the
2>&1 >/dev/null
means that warnings raised now get mingled in the laterecho $?
and thus make the equality check for0
fail -- tools are then not detected any more.Testing procedure
Try building anything on a recent Debian sid system; it will fail before with
and now run through.
Issues/PRs references
debianutils' which, in its changelog, states:
Note that this PR does not change which to command, it just fixes the fallout of ill-sequenced redirects. That change is probably good to do, but right now this should be minimal enough to get merged quickly, and I don't want it held up in the question of whether everyone and their dog already implement POSIX
command
.