{"thread":{"id":"41927","subject":"[PATCH] Makefile: fix misdirected redirections","startedAt":"2016-04-05T07:02:14Z","lastAt":"2016-04-05T07:02:14Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"282689","messageId":"xmqqshz035e1.fsf@gitster.mtv.corp.google.com","threadId":"41927","inReplyTo":null,"subject":"[PATCH] Makefile: fix misdirected redirections","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-05T07:02:14Z","receivedAt":"2016-04-05T07:02:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In general \"echo 2>&1 $msg\" to redirect a possible error message\nthat comes from 'echo' itself into the same standard output stream\n$msg is getting written to does not make any sense; it is not like\nwe are expecting to see any errors out of 'echo' in these statements,\nand even if it were the case, there is no reason to prevent the\nerror messages from being sent to the standard error stream.\n\nThese are clearly meant to send the argument given to echo to the\nstandard error stream as error messages.  Correctly redirect by\nsaying \"send what is written to the standard output to the standard\nerror\", i.e. \"1>&2\" aka \">&2\".\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * There are two more uses of 2>&1 in the Makefile, and they are\n   correct.\n\n   - The one in dep_check one is used as\n\n       dep_check = $(shell ... 2>&1; echo $$?)\n\n     and it is an attempt to make sure that anything sent to the\n     standard error is not leaked out of the shell substitution.  It\n     does want to send whatever is written to the standard error\n     instead written to the standard output.\n\n   - The other is \"cmp ... >/dev/null 2>&1\", which is a typical way\n     to squelch both the standard output and the standard error for\n     any command.\n\n Makefile | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8700db8..296f175 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2211,10 +2211,10 @@ sparse: $(SP_OBJ)\n check: common-cmds.h\n \t@if sparse; \\\n \tthen \\\n-\t\techo 2>&1 \"Use 'make sparse' instead\"; \\\n+\t\techo >&2 \"Use 'make sparse' instead\"; \\\n \t\t$(MAKE) --no-print-directory sparse; \\\n \telse \\\n-\t\techo 2>&1 \"Did you mean 'make test'?\"; \\\n+\t\techo >&2 \"Did you mean 'make test'?\"; \\\n \t\texit 1; \\\n \tfi\n \n"}]}