mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	test/[: use a shell state bit (re: 7003aba4)
				
					
				
			Instead of a global 'sh_in_test_builtin' integer flag, it is nicer to use the mechanism for shell state bits, which was designed for this sort of thing. src/cmd/ksh93/include/defs.h, src/cmd/ksh93/sh/defs.c: - Remove global sh_in_test_builtin integer. - Define new SH_INTESTCMD state bit. src/cmd/ksh93/bltins/test.c: _ERROR_exit_b_test(), b_test(): - Use the new state bit.
This commit is contained in:
		
							parent
							
								
									42301639d6
								
							
						
					
					
						commit
						cd2cf236c2
					
				
					 3 changed files with 5 additions and 6 deletions
				
			
		|  | @ -89,9 +89,9 @@ static int e3(struct test*); | |||
|  */ | ||||
| int _ERROR_exit_b_test(int exitval) | ||||
| { | ||||
| 	if(sh_in_test_builtin) | ||||
| 	if(sh_isstate(SH_INTESTCMD)) | ||||
| 	{ | ||||
| 		sh_in_test_builtin = 0; | ||||
| 		sh_offstate(SH_INTESTCMD); | ||||
| 		if(exitval < 2) | ||||
| 			exitval = 2; | ||||
| 	} | ||||
|  | @ -133,7 +133,7 @@ int b_test(int argc, char *argv[],Shbltin_t *context) | |||
| 	register int not; | ||||
| 	int exitval; | ||||
| 
 | ||||
| 	sh_in_test_builtin = 1; | ||||
| 	sh_onstate(SH_INTESTCMD); | ||||
| 	tdata.sh = context->shp; | ||||
| 	tdata.av = argv; | ||||
| 	tdata.ap = 1; | ||||
|  | @ -226,7 +226,7 @@ int b_test(int argc, char *argv[],Shbltin_t *context) | |||
| 	tdata.ac = argc; | ||||
| 	exitval = (!expr(&tdata,0)); | ||||
| done: | ||||
| 	sh_in_test_builtin = 0; | ||||
| 	sh_offstate(SH_INTESTCMD); | ||||
| 	return(exitval); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -309,6 +309,7 @@ struct shared | |||
| #define	SH_FCOMPLETE	17	/* set for filename completion */ | ||||
| #define	SH_PREINIT	18	/* set with SH_INIT before parsing options */ | ||||
| #define SH_COMPLETE	19	/* set for command completion */ | ||||
| #define SH_INTESTCMD	20	/* set while test/[ command is being run */ | ||||
| 
 | ||||
| #define SH_BASH			41 | ||||
| #define SH_BRACEEXPAND		42 | ||||
|  | @ -507,7 +508,6 @@ extern const char	e_dict[]; | |||
| #   define sh_stats(x) | ||||
| #endif /* SHOPT_STATS */ | ||||
| 
 | ||||
| extern int		sh_in_test_builtin; | ||||
| extern int		_ERROR_exit_b_test(int); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -46,4 +46,3 @@ char *sh_lexstates[ST_NONE] = {0}; | |||
| struct jobs	job = {0}; | ||||
| int32_t		sh_mailchk = 600; | ||||
| 
 | ||||
| int		sh_in_test_builtin = 0; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue