ash: fix ignoreeof option
The ignoreeof option should prevent an interactive shell from exiting on EOF. This hasn't worked in BusyBox ash since commit727752d2d(ash: better fix for ash -c 'echo 5&' and ash -c 'sleep 5&' with testcase). Commit3b4d04b77e(ash: input: Allow two consecutive calls to pungetc) pulled in improved support for multiple calls to pungetc from dash, thus rendering much of commit727752d2dobsolete. Removing this old code fixes the problem with ignoreeof. function old new delta __pgetc 605 587 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-18) Total: -18 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
		
				
					committed by
					
						 Denys Vlasenko
						Denys Vlasenko
					
				
			
			
				
	
			
			
			
						parent
						
							9346ea9550
						
					
				
				
					commit
					0beee20977
				
			
							
								
								
									
										22
									
								
								shell/ash.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								shell/ash.c
									
									
									
									
									
								
							| @@ -10826,9 +10826,7 @@ preadfd(void) | ||||
|  * Refill the input buffer and return the next input character: | ||||
|  * | ||||
|  * 1) If a string was pushed back on the input, pop it; | ||||
|  * 2) If an EOF was pushed back (g_parsefile->left_in_line < -BIGNUM) | ||||
|  *    or we are reading from a string so we can't refill the buffer, | ||||
|  *    return EOF. | ||||
|  * 2) If we are reading from a string we can't refill the buffer, return EOF. | ||||
|  * 3) If there is more stuff in this buffer, use it else call read to fill it. | ||||
|  * 4) Process input up to the next newline, deleting nul characters. | ||||
|  */ | ||||
| @@ -10845,21 +10843,9 @@ preadbuffer(void) | ||||
| 		popstring(); | ||||
| 		return __pgetc(); | ||||
| 	} | ||||
| 	/* on both branches above g_parsefile->left_in_line < 0. | ||||
| 	 * "pgetc" needs refilling. | ||||
| 	 */ | ||||
|  | ||||
| 	/* -90 is our -BIGNUM. Below we use -99 to mark "EOF on read", | ||||
| 	 * pungetc() may increment it a few times. | ||||
| 	 * Assuming it won't increment it to less than -90. | ||||
| 	 */ | ||||
| 	if (g_parsefile->left_in_line < -90 || g_parsefile->buf == NULL) { | ||||
| 	if (g_parsefile->buf == NULL) { | ||||
| 		pgetc_debug("preadbuffer PEOF1"); | ||||
| 		/* even in failure keep left_in_line and next_to_pgetc | ||||
| 		 * in lock step, for correct multi-layer pungetc. | ||||
| 		 * left_in_line was decremented before preadbuffer(), | ||||
| 		 * must inc next_to_pgetc: */ | ||||
| 		g_parsefile->next_to_pgetc++; | ||||
| 		return PEOF; | ||||
| 	} | ||||
|  | ||||
| @@ -10869,10 +10855,8 @@ preadbuffer(void) | ||||
|  again: | ||||
| 		more = preadfd(); | ||||
| 		if (more <= 0) { | ||||
| 			/* don't try reading again */ | ||||
| 			g_parsefile->left_in_line = -99; | ||||
| 			g_parsefile->left_in_buffer = g_parsefile->left_in_line = 0; | ||||
| 			pgetc_debug("preadbuffer PEOF2"); | ||||
| 			g_parsefile->next_to_pgetc++; | ||||
| 			return PEOF; | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user