[PATCH] shell: Add support for building without tee(2)

Herbert Xu <[email protected]> Wed, 28 Jan 2026 12:31:35 +0800
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
In order to test the fallback path when tee(2) is not available,
allow tee(2) to be disabled with --disable-tee.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/configure.ac b/configure.ac
index 5efd9e2..89759c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,7 @@ fi
 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \
 				      [Use fnmatch(3) from libc]))
 AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
+AC_ARG_ENABLE(tee, AS_HELP_STRING(--disable-tee, [Do not use tee(2)]))
 
 dnl Checks for libraries.
 
@@ -131,6 +132,12 @@ if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
 	AC_CHECK_FUNCS(glob)
 fi
 
+if test "$enable_tee" != no; then
+	AC_DEFINE([USE_TEE], [1], [Non-zero if tee(2) should be used])
+else
+	AC_DEFINE([USE_TEE], [0], [Non-zero if tee(2) should be used])
+fi
+
 dnl Check for klibc signal.
 AC_CHECK_FUNC(signal)
 if test "$ac_cv_func_signal" != yes; then
diff --git a/src/input.c b/src/input.c
index c36d120..06f1ecc 100644
--- a/src/input.c
+++ b/src/input.c
@@ -185,7 +185,7 @@ static int stdin_tee(void *buf, int nr)
 
 	flush_tee(buf, nr, stdin_state.pending);
 
-	err = tee(0, stdin_state.pip[1], nr, 0);
+	err = USE_TEE ? tee(0, stdin_state.pip[1], nr, 0) : -1;
 	stdin_state.pending = err;
 	return err;
 }
-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt