Skip to contentSkip to conversation

input: Call input_init on first use

PATCH New Herbert Xu 1 participant 1 message Aug 24, 2025

lore
Share & tools
lore

Herbert Xu

author
#0 lore raw

PATCH 1/1 input: Call input_init on first use

When the shell is used to execute another utility, it makes no sense to initialise stdin, which costs up to two system calls.

Since the input layer can already handle first-use initialisation because of reset_init, simply make this always the case.

src/input.c +1 -3
index 1aff3d4..c36d120 100644
@@ -77,7 +77,7 @@ MKINIT struct parsefile *toppf = &basepf;
 MKINIT struct stdin_state stdin_state;
 struct parsefile *parsefile = &basepf;	/* current input file */
 int whichprompt;		/* 1 == PS1, 2 == PS2 */
-int stdin_istty;
+int stdin_istty = -1;
 
 MKINIT void input_init(void);
 
@@ -99,8 +99,6 @@ INCLUDE "syntax.h"
 INIT {
 	basepf.nextc = basepf.buf = basebuf;
 	basepf.linno = 1;
-
-	input_init();
 }
 
 RESET {

--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt