refactor(tools): refact shell codes
This commit is contained in:
parent
bce784ab51
commit
c92b3ce226
|
@ -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(®ex, 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, ®ex, msgbuf, sizeof(msgbuf));
|
||||
fprintf(stderr, "Regex match failed: %s\n", msgbuf);
|
||||
regfree(®ex);
|
||||
return false;
|
||||
shellExit();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -114,3 +114,5 @@ void shellCheckServerStatus() {
|
|||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void shellExit() { exit(EXIT_FAILURE); }
|
Loading…
Reference in New Issue