diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 37499d23502913b51878cbddbe12f4590106698f..60cf4a4ea685e58b303bf89ed8fa61729110f999 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -248,6 +248,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { char * cptr = NULL; char * fname = NULL; bool printMode = false; + int match; sptr = command; while ((sptr = tstrstr(sptr, ">>", true)) != NULL) { @@ -259,18 +260,24 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { sptr = tmp; if (sptr != NULL) { - if (regex_match(sptr + 2, "^\\s*[0-9]+\\s*[\\>|\\<|\\<=|\\>=|=|!=]\\s*.*;\\s*$", REG_EXTENDED | REG_ICASE) == 0) { - cptr = tstrstr(command, ";", true); - if (cptr != NULL) { - *cptr = '\0'; + // select ... where col >> n op m ...; + match = regex_match(sptr + 2, "^\\s*[0-9]{1,}\\s*[\\>|\\<|\\<=|\\>=|=|!=]\\s*.*;\\s*$", REG_EXTENDED | REG_ICASE); + if (match == 0) { + // select col >> n from ...; + match = regex_match(sptr + 2, "^\\s*[0-9]{1,}\\s*.*;\\s*$", REG_EXTENDED | REG_ICASE); + if (match == 0) { + cptr = tstrstr(command, ";", true); + if (cptr != NULL) { + *cptr = '\0'; + } + + if (wordexp(sptr + 2, &full_path, 0) != 0) { + fprintf(stderr, "ERROR: invalid filename: %s\n", sptr + 2); + return; + } + *sptr = '\0'; + fname = full_path.we_wordv[0]; } - - if (wordexp(sptr + 2, &full_path, 0) != 0) { - fprintf(stderr, "ERROR: invalid filename: %s\n", sptr + 2); - return; - } - *sptr = '\0'; - fname = full_path.we_wordv[0]; } }