[PATCH v2] libtraceevent: Fix the /dev/null redirection compatibility in Makefile

Haiyue Wang <[email protected]> Tue, 13 May 2025 18:23:08 +0800
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
The commit c2ea03541453 ("libtraceevent: Add trace.conf for ld.so if needed")
runs with below output message, and the built 'test' will not be removed as
expected.

  INSTALL     /root/linux/libtraceevent/lib/libtraceevent.so.1.8.4      to      /usr/local/lib64
  INSTALL      trace.conf       to       /etc/ld.so.conf.d/
/bin/sh: 1: /root/linux/libtraceevent/test: not found
  DESCEND            plugins

Use more compatible syntax to handle shell null redirection.

Signed-off-by: Haiyue Wang <[email protected]>
---
v2:
  - Find the root cause why test is not removed as expected.
v1: https://lore.kernel.org/linux-trace-devel/[email protected]/
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 0afaef0..b559b6d 100644
--- a/Makefile
+++ b/Makefile
@@ -317,8 +317,8 @@ define install_ld_config
 	if $(LDCONFIG); then \
 		if ! grep -q "^$(libdir)$$" $(LD_SO_CONF_PATH)/* ; then \
 			$(CC) -o $(objtree)/test $(srctree)/test.c -I $(includedir_SQ) \
-				-L $(libdir_SQ) -ltraceevent &> /dev/null; \
-			if ! $(objtree)/test &> /dev/null; then \
+				-L $(libdir_SQ) -ltraceevent > /dev/null 2>&1; \
+			if ! $(objtree)/test > /dev/null 2>&1; then \
 				$(call print_install, trace.conf, $(LD_SO_CONF_PATH)) \
 				echo $(libdir_SQ) >> $(LD_SO_CONF_PATH)/trace.conf; \
 				$(LDCONFIG); \
-- 
2.49.0