refactor(tools): refact shell codes
This commit is contained in:
parent
d2d5196186
commit
bce784ab51
|
@ -207,7 +207,6 @@ static struct argp_option shellOptions[] = {
|
|||
|
||||
static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) {
|
||||
SShellArgs *arguments = &shell.args;
|
||||
wordexp_t full_path = {0};
|
||||
|
||||
switch (key) {
|
||||
case 'h':
|
||||
|
|
|
@ -177,12 +177,11 @@ int32_t shellRunCommand(char *command) {
|
|||
}
|
||||
|
||||
void shellRunSingleCommandImp(char *command) {
|
||||
int64_t st, et;
|
||||
wordexp_t full_path;
|
||||
char *sptr = NULL;
|
||||
char *cptr = NULL;
|
||||
char *fname = NULL;
|
||||
bool printMode = false;
|
||||
int64_t st, et;
|
||||
char *sptr = NULL;
|
||||
char *cptr = NULL;
|
||||
char *fname = NULL;
|
||||
bool printMode = false;
|
||||
|
||||
if ((sptr = strstr(command, ">>")) != NULL) {
|
||||
cptr = strstr(command, ";");
|
||||
|
@ -250,10 +249,6 @@ void shellRunSingleCommandImp(char *command) {
|
|||
|
||||
printf("\n");
|
||||
|
||||
if (fname != NULL) {
|
||||
wordfree(&full_path);
|
||||
}
|
||||
|
||||
atomic_store_64(&shell.result, 0);
|
||||
}
|
||||
|
||||
|
@ -396,7 +391,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
|
|||
row = taos_fetch_row(tres);
|
||||
} while (row != NULL);
|
||||
|
||||
shell.result = 0;
|
||||
atomic_store_64(&shell.result, 0);
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
return numOfRows;
|
||||
|
@ -862,7 +857,7 @@ void shellGetGrantInfo() {
|
|||
taos_get_server_info(shell.conn), expiretime);
|
||||
}
|
||||
|
||||
shell.result = 0;
|
||||
atomic_store_64(&shell.result, 0);
|
||||
taos_free_result(tres);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ SShellObj shell = {0};
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (shellCheckIntSize() != 0) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (shellParseArgs(argc, argv) != 0) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (shell.args.is_version) {
|
||||
|
@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if (shell.args.is_help) {
|
||||
shellPrintVersion();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue