提交 c92b3ce2 编写于 作者: S Shengliang Guan

refactor(tools): refact shell codes

上级 bce784ab
......@@ -97,6 +97,7 @@ void shellGenerateAuth();
void shellDumpConfig();
void shellCheckServerStatus();
bool shellRegexMatch(const char* s, const char* reg, int32_t cflags);
void shellExit();
// shellNettest.c
void shellTestNetWork();
......
......@@ -278,7 +278,7 @@ static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""};
static void shellParseArgsInLinux(int argc, char *argv[]) {
argp_program_version = shell.info.programVersion;
argp_parse(&shellArgp, argc, argv, 0, 0, NULL);
argp_parse(&shellArgp, argc, argv, 0, 0, &shell.args);
}
#endif
......
......@@ -907,6 +907,8 @@ void *shellThreadLoop(void *arg) {
} while (shellRunCommand(command) == 0);
taosMemoryFreeClear(command);
// shellExit();
taosThreadCleanupPop(1);
return NULL;
}
......
......@@ -56,7 +56,8 @@ int main(int argc, char *argv[]) {
return 0;
}
if (strcmp(shell.args.netrole, "client") == 0 || strcmp(shell.args.netrole, "server") == 0) {
if (shell.args.netrole != NULL &&
(strcmp(shell.args.netrole, "client") == 0 || strcmp(shell.args.netrole, "server")) == 0) {
shellTestNetWork();
taos_cleanup();
return 0;
......
......@@ -21,13 +21,13 @@
#include "shellInt.h"
bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
regex_t regex;
regex_t regex = {0};
char msgbuf[100] = {0};
/* Compile regular expression */
if (regcomp(&regex, reg, cflags) != 0) {
fprintf(stderr, "Fail to compile regex");
return false;
shellExit();
}
/* Execute regular expression */
......@@ -42,7 +42,7 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
regerror(reti, &regex, msgbuf, sizeof(msgbuf));
fprintf(stderr, "Regex match failed: %s\n", msgbuf);
regfree(&regex);
return false;
shellExit();
}
return false;
......@@ -114,3 +114,5 @@ void shellCheckServerStatus() {
}
} while (1);
}
void shellExit() { exit(EXIT_FAILURE); }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册