blob: d82d3c9e4543c016c10e80fb899bfa859c70edd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
* Reuse the standalone test(1) parser as the shell builtin entry point.
* The external source now exports main() and exits on syntax errors, so
* provide a wrapper that maps its process-exit path back to a builtin
* return value.
*/
#include <setjmp.h>
#include <stdio.h>
static jmp_buf testcmd_jmp;
static int testcmd_status;
static void
testcmd_exit(int status)
{
testcmd_status = status;
fflush(NULL);
longjmp(testcmd_jmp, 1);
}
#define exit testcmd_exit
#define main testcmd_main
#include "../../bin/test/test.c"
#undef main
#undef exit
int
testcmd(int argc, char **argv)
{
if (setjmp(testcmd_jmp) != 0)
return testcmd_status;
return testcmd_main(argc, argv);
}
|