1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

test/[: rm SH_INTESTCMD; test for 'test' directly (re: cd2cf236)

Turns out there is a way to check what built-in we're running at
any time. It is done for 'let' in arith.c:
    sh.bltindata.bnode==SYSLET
For test/[, that would be (see include/builtins.h):
    sh.bltindata.bnode==SYSTEST || sh.bltindata.bnode==SYSBRACKET
This commit is contained in:
Martijn Dekker 2021-11-15 06:53:45 +01:00
parent a4375f3090
commit ef1f53b5b2
2 changed files with 2 additions and 9 deletions

View file

@ -90,12 +90,8 @@ static int e3(struct test*);
*/
int _ERROR_exit_b_test(int exitval)
{
if(sh_isstate(SH_INTESTCMD))
{
sh_offstate(SH_INTESTCMD);
if(exitval < 2)
exitval = 2;
}
if((sh.bltindata.bnode==SYSTEST || sh.bltindata.bnode==SYSBRACKET) && exitval < 2)
exitval = 2;
return(ERROR_exit(exitval));
}
#undef ERROR_exit
@ -134,7 +130,6 @@ int b_test(int argc, char *argv[],Shbltin_t *context)
register int not;
int exitval;
sh_onstate(SH_INTESTCMD);
tdata.sh = context->shp;
tdata.av = argv;
tdata.ap = 1;
@ -237,7 +232,6 @@ int b_test(int argc, char *argv[],Shbltin_t *context)
tdata.ac = argc;
exitval = (!expr(&tdata,0));
done:
sh_offstate(SH_INTESTCMD);
return(exitval);
}

View file

@ -76,7 +76,6 @@ typedef union Shnode_u Shnode_t;
#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_XARG 21 /* set while in xarg (command -x) mode */
/*