• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #3620

21 Feb 2025 09:00AM UTC coverage: 63.573% (+0.2%) from 63.423%
#3620

push

travis-ci

web-flow
ci: taosBenchmark add coverage cases branch 3.0 (#29788)

* fix: add unit test for taos-tools

* fix: only .cpp include

* fix: remove no use function

* fix: restore toolsSys.c

* fix: add toolsSys case

* fix: rebuild error fixed

* fix: fix build error

* fix: support get vgroups with core and memory limit

* fix: build error for strcasecmp

* fix: add insertBasic.py case

* fix: add command line set vgroups=3

* fix: change with ns database

* toolscJson read with int replace float and add insertPrecison.py

* fix: add insertBindVGroup.json case

* fix: remove public fun removeQuotation

* fix: vgroups change method

* fix: memory leak for runInsertLimitThread slot

* insertPrecision.py word write wrong

* fix: check isFloat number

* fix: vgroups change logic error

* fix: insertBasic.py real and expect error

* fix: adjust default vgroups

* fix: adjust default vgroups modify comment

148962 of 300203 branches covered (49.62%)

Branch coverage included in aggregate %.

15 of 16 new or added lines in 1 file covered. (93.75%)

2018 existing lines in 133 files now uncovered.

233201 of 300933 relevant lines covered (77.49%)

18174406.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.63
/tools/shell/src/shellArguments.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#ifdef _TD_DARWIN_64
17
#include <pwd.h>
18
#endif
19

20
#include "cus_name.h"
21
#include "shellInt.h"
22
#include "version.h"
23

24

25
#define TAOS_CONSOLE_PROMPT_CONTINUE "   -> "
26

27
#define SHELL_HOST     "The server FQDN to connect. The default host is localhost."
28
#define SHELL_PORT     "The TCP/IP port number to use for the connection."
29
#define SHELL_USER     "The user name to use when connecting to the server."
30
#define SHELL_PASSWORD "The password to use when connecting to the server."
31
#define SHELL_AUTH     "The auth string to use when connecting to the server."
32
#define SHELL_GEN_AUTH "Generate auth string from password."
33
#define SHELL_CFG_DIR  "Configuration directory."
34
#define SHELL_DMP_CFG  "Dump configuration."
35
#define SHELL_CMD      "Commands to run without enter the shell."
36
#define SHELL_RAW_TIME "Output time as uint64_t."
37
#define SHELL_FILE     "Script to run without enter the shell."
38
#define SHELL_DB       "Database to use when connecting to the server."
39
#define SHELL_CHECK    "Check the service status."
40
#define SHELL_STARTUP  "Check the details of the service status."
41
#define SHELL_WIDTH    "Set the default binary display width, default is 30."
42
#define SHELL_NET_ROLE "Net role when network connectivity test, options: client|server."
43
#define SHELL_PKT_LEN  "Packet length used for net test, default is 1024 bytes."
44
#define SHELL_PKT_NUM  "Packet numbers used for net test, default is 100."
45
#define SHELL_BI_MODE  "Set BI mode"
46
#define SHELL_LOG_OUTPUT                                                                                              \
47
  "Specify log output. Options:\n\r\t\t\t     stdout, stderr, /dev/null, <directory>, <directory>/<filename>, "       \
48
  "<filename>\n\r\t\t\t     * If OUTPUT contains an absolute directory, logs will be stored in that directory "       \
49
  "instead of logDir.\n\r\t\t\t     * If OUTPUT contains a relative directory, logs will be stored in the directory " \
50
  "combined with logDir and the relative directory."
51
#define SHELL_VERSION "Print program version."
52

53
#ifdef WEBSOCKET
54
#define SHELL_DSN     "Use dsn to connect to the cloud server or to a remote server which provides WebSocket connection."
55
#define SHELL_REST    "Use RESTful mode when connecting."
56
#define SHELL_TIMEOUT "Set the timeout for websocket query in seconds, default is 30."
57
#endif
58

59
static int32_t shellParseSingleOpt(int32_t key, char *arg);
60

61
void shellPrintHelp() {
×
62
  char indent[] = "  ";
×
63
  printf("Usage: %s [OPTION...] \r\n\r\n", CUS_PROMPT);
×
64
  printf("%s%s%s%s\r\n", indent, "-a,", indent, SHELL_AUTH);
×
65
  printf("%s%s%s%s\r\n", indent, "-A,", indent, SHELL_GEN_AUTH);
×
66
  printf("%s%s%s%s\r\n", indent, "-B,", indent, SHELL_BI_MODE);
×
67
  printf("%s%s%s%s\r\n", indent, "-c,", indent, SHELL_CFG_DIR);
×
68
  printf("%s%s%s%s\r\n", indent, "-C,", indent, SHELL_DMP_CFG);
×
69
  printf("%s%s%s%s\r\n", indent, "-d,", indent, SHELL_DB);
×
70
  printf("%s%s%s%s\r\n", indent, "-f,", indent, SHELL_FILE);
×
71
  printf("%s%s%s%s\r\n", indent, "-h,", indent, SHELL_HOST);
×
72
  printf("%s%s%s%s\r\n", indent, "-k,", indent, SHELL_CHECK);
×
73
  printf("%s%s%s%s\r\n", indent, "-l,", indent, SHELL_PKT_LEN);
×
74
  printf("%s%s%s%s\r\n", indent, "-n,", indent, SHELL_NET_ROLE);
×
75
  printf("%s%s%s%s\r\n", indent, "-N,", indent, SHELL_PKT_NUM);
×
76
#if defined(LINUX)
77
  printf("%s%s%s%s\r\n", indent, "-o,", indent, SHELL_LOG_OUTPUT);
×
78
#endif
79
  printf("%s%s%s%s\r\n", indent, "-p,", indent, SHELL_PASSWORD);
×
80
  printf("%s%s%s%s\r\n", indent, "-P,", indent, SHELL_PORT);
×
81
  printf("%s%s%s%s\r\n", indent, "-r,", indent, SHELL_RAW_TIME);
×
82
  printf("%s%s%s%s\r\n", indent, "-s,", indent, SHELL_CMD);
×
83
  printf("%s%s%s%s\r\n", indent, "-t,", indent, SHELL_STARTUP);
×
84
  printf("%s%s%s%s\r\n", indent, "-u,", indent, SHELL_USER);
×
85
#ifdef WEBSOCKET
86
  printf("%s%s%s%s\r\n", indent, "-E,", indent, SHELL_DSN);
×
87
  printf("%s%s%s%s\r\n", indent, "-R,", indent, SHELL_REST);
×
88
  printf("%s%s%s%s\r\n", indent, "-T,", indent, SHELL_TIMEOUT);
×
89
#endif
90
  printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
×
91
  printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
×
92
#ifdef CUS_EMAIL
93
  printf("\r\n\r\nReport bugs to %s.\r\n", CUS_EMAIL);
×
94
#else
95
  printf("\r\n\r\nReport bugs to %s.\r\n", "support@taosdata.com");
96
#endif
97
}
×
98

99
#ifdef LINUX
100
#include <argp.h>
101
#ifdef _ALPINE
102
#include <termios.h>
103
#else
104
#include <termio.h>
105
#endif
106

107
const char *argp_program_version = td_version;
108
#ifdef CUS_EMAIL
109
const char *argp_program_bug_address = CUS_EMAIL;
110
#else
111
const char *argp_program_bug_address = "support@taosdata.com";
112
#endif
113

114
static struct argp_option shellOptions[] = {
115
    {"host", 'h', "HOST", 0, SHELL_HOST},
116
    {"port", 'P', "PORT", 0, SHELL_PORT},
117
    {"user", 'u', "USER", 0, SHELL_USER},
118
    {0, 'p', 0, 0, SHELL_PASSWORD},
119
    {"auth", 'a', "AUTH", 0, SHELL_AUTH},
120
    {"generate-auth", 'A', 0, 0, SHELL_GEN_AUTH},
121
    {"config-dir", 'c', "DIR", 0, SHELL_CFG_DIR},
122
    {"dump-config", 'C', 0, 0, SHELL_DMP_CFG},
123
    {"commands", 's', "COMMANDS", 0, SHELL_CMD},
124
    {"raw-time", 'r', 0, 0, SHELL_RAW_TIME},
125
    {"file", 'f', "FILE", 0, SHELL_FILE},
126
    {"database", 'd', "DATABASE", 0, SHELL_DB},
127
    {"check", 'k', 0, 0, SHELL_CHECK},
128
    {"startup", 't', 0, 0, SHELL_STARTUP},
129
    {"display-width", 'w', "WIDTH", 0, SHELL_WIDTH},
130
    {"netrole", 'n', "NETROLE", 0, SHELL_NET_ROLE},
131
    {"pktlen", 'l', "PKTLEN", 0, SHELL_PKT_LEN},
132
#ifdef WEBSOCKET
133
    {"dsn", 'E', "DSN", 0, SHELL_DSN},
134
    {"restful", 'R', 0, 0, SHELL_REST},
135
    {"timeout", 'T', "SECONDS", 0, SHELL_TIMEOUT},
136
#endif
137
    {"pktnum", 'N', "PKTNUM", 0, SHELL_PKT_NUM},
138
    {"bimode", 'B', 0, 0, SHELL_BI_MODE},
139
#if defined(LINUX)
140
    {"log-output", 'o', "OUTPUT", 0, SHELL_LOG_OUTPUT},
141
#endif
142
    {0},
143
};
144

145
static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); }
7,636✔
146

147
static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""};
148

149
static void shellParseArgsUseArgp(int argc, char *argv[]) {
1,131✔
150
  argp_program_version = shell.info.programVersion;
1,131✔
151
  argp_parse(&shellArgp, argc, argv, 0, 0, &shell.args);
1,131✔
152
}
1,111✔
153

154
#endif
155

156
#ifndef ARGP_ERR_UNKNOWN
157
#define ARGP_ERR_UNKNOWN E2BIG
158
#endif
159

160
static int32_t shellParseSingleOpt(int32_t key, char *arg) {
7,636✔
161
  SShellArgs *pArgs = &shell.args;
7,636✔
162

163
  switch (key) {
7,636!
164
    case 'h':
714✔
165
      pArgs->host = arg;
714✔
166
#ifdef WEBSOCKET
167
      pArgs->cloud = false;
714✔
168
#endif
169
      break;
714✔
170
    case 'P':
79✔
171
      pArgs->port = atoi(arg);
79✔
172
#ifdef WEBSOCKET
173
      pArgs->cloud = false;
79✔
174
#endif
175
      if (pArgs->port == 0) pArgs->port = -1;
79✔
176
      break;
79✔
177
    case 'u':
5✔
178
      pArgs->user = arg;
5✔
179
      break;
5✔
180
    case 'p':
4✔
181
      break;
4✔
182
    case 'a':
3✔
183
      pArgs->auth = arg;
3✔
184
      break;
3✔
185
    case 'A':
1✔
186
      pArgs->is_gen_auth = true;
1✔
187
      break;
1✔
188
    case 'B':
1✔
189
      pArgs->is_bi_mode = true;
1✔
190
      break;
1✔
191
    case 'c':
147✔
192
#ifdef WEBSOCKET
193
      pArgs->cloud = false;
147✔
194
#endif
195
      pArgs->cfgdir = arg;
147✔
196
      break;
147✔
197
    case 'C':
1✔
198
      pArgs->is_dump_config = true;
1✔
199
      break;
1✔
200
    case 's':
229✔
201
      pArgs->commands = arg;
229✔
202
      break;
229✔
203
    case 'r':
1✔
204
      pArgs->is_raw_time = true;
1✔
205
      break;
1✔
206
    case 'f':
851✔
207
      tstrncpy(pArgs->file, arg, sizeof(pArgs->file));
851✔
208
      break;
851✔
209
    case 'd':
4✔
210
      pArgs->database = arg;
4✔
211
      break;
4✔
212
    case 'k':
3✔
213
      pArgs->is_check = true;
3✔
214
      break;
3✔
215
    case 't':
1✔
216
      pArgs->is_startup = true;
1✔
217
      break;
1✔
218
    case 'w':
2✔
219
      pArgs->displayWidth = atoi(arg);
2✔
220
      break;
2✔
221
    case 'n':
1✔
222
      pArgs->netrole = arg;
1✔
223
      break;
1✔
224
    case 'l':
2✔
225
      pArgs->pktLen = atoi(arg);
2✔
226
      break;
2✔
227
    case 'N':
2✔
228
      pArgs->pktNum = atoi(arg);
2✔
229
      break;
2✔
230
#if defined(LINUX)
231
    case 'o':
6✔
232
      if (strlen(arg) >= PATH_MAX) {
6!
233
        printf("failed to set log output since length overflow, max length is %d\n", PATH_MAX);
×
234
        return TSDB_CODE_INVALID_CFG;
×
235
      }
236
      tsLogOutput = taosMemoryMalloc(PATH_MAX);
6!
237
      if (!tsLogOutput) {
6!
238
        printf("failed to set log output: '%s' since %s\n", arg, tstrerror(terrno));
×
239
        return terrno;
×
240
      }
241
      if (taosExpandDir(arg, tsLogOutput, PATH_MAX) != 0) {
6!
242
        printf("failed to expand log output: '%s' since %s\n", arg, tstrerror(terrno));
×
243
        return terrno;
×
244
      }
245
      break;
6✔
246
#endif
247
#ifdef WEBSOCKET
UNCOV
248
    case 'R':
×
UNCOV
249
      pArgs->restful = true;
×
UNCOV
250
      break;
×
UNCOV
251
    case 'E':
×
UNCOV
252
      pArgs->dsn = arg;
×
UNCOV
253
      pArgs->cloud = true;
×
UNCOV
254
      break;
×
UNCOV
255
    case 'T':
×
UNCOV
256
      pArgs->timeout = atoi(arg);
×
UNCOV
257
      break;
×
258
#endif
259
    case 'V':
×
260
      pArgs->is_version = true;
×
261
      break;
×
262
    case '?':
×
263
      pArgs->is_help = true;
×
264
      break;
×
265
    case 1:
×
266
      pArgs->abort = 1;
×
267
      break;
×
268
    default:
5,579✔
269
      return ARGP_ERR_UNKNOWN;
5,579✔
270
  }
271
  return 0;
2,057✔
272
}
273
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined(_TD_DARWIN_64)
274
int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
275
  SShellArgs *pArgs = &shell.args;
276

277
  for (int i = 1; i < argc; i++) {
278
    if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0
279
            || strcmp(argv[i], "-?") == 0 || strcmp(argv[i], "/?") == 0) {
280
      shellParseSingleOpt('?', NULL);
281
      return 0;
282
    }
283

284
    char   *key = argv[i];
285
    int32_t keyLen = strlen(key);
286
    if (keyLen != 2) {
287
      fprintf(stderr, "invalid option %s\r\n", key);
288
      return -1;
289
    }
290
    if (key[0] != '-') {
291
      fprintf(stderr, "invalid option %s\r\n", key);
292
      return -1;
293
    }
294

295
    if (key[1] == 'h' || key[1] == 'P' || key[1] == 'u'
296
            || key[1] == 'a' || key[1] == 'c' || key[1] == 's'
297
            || key[1] == 'f' || key[1] == 'd' || key[1] == 'w'
298
            || key[1] == 'n' || key[1] == 'l' || key[1] == 'N'
299
#ifdef WEBSOCKET
300
        || key[1] == 'E' || key[1] == 'T'
301
#endif
302
    ) {
303
      if (i + 1 >= argc) {
304
        fprintf(stderr, "option %s requires an argument\r\n", key);
305
        return -1;
306
      }
307
      char *val = argv[i + 1];
308
      if (val[0] == '-') {
309
        fprintf(stderr, "option %s requires an argument\r\n", key);
310
        return -1;
311
      }
312
      shellParseSingleOpt(key[1], val);
313
      i++;
314
    } else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'C'
315
                || key[1] == 'r' || key[1] == 'k'
316
                || key[1] == 't' || key[1] == 'V'
317
                || key[1] == '?' || key[1] == 1
318
#ifdef WEBSOCKET
319
            ||key[1] == 'R'
320
#endif
321
    ) {
322
      shellParseSingleOpt(key[1], NULL);
323
    } else {
324
      fprintf(stderr, "invalid option %s\r\n", key);
325
      return -1;
326
    }
327
  }
328

329
  return 0;
330
}
331
#endif
332

333
static void shellInitArgs(int argc, char *argv[]) {
1,131✔
334
  for (int i = 1; i < argc; i++) {
5,245✔
335
    if (strncmp(argv[i], "-p", 2) == 0) {
4,114✔
336
      // printf(shell.info.clientVersion, taos_get_client_info());
337
      if (strlen(argv[i]) == 2) {
4!
338
        printf("Enter password: ");
×
339
        taosSetConsoleEcho(false);
×
340
        if (scanf("%128s", shell.args.password) > 1) {
×
341
          fprintf(stderr, "password reading error\n");
×
342
        }
343
        taosSetConsoleEcho(true);
×
344
        if (EOF == getchar()) {
×
345
          fprintf(stderr, "getchar() return EOF\r\n");
×
346
        }
347
      } else {
348
        tstrncpy(shell.args.password, (char *)(argv[i] + 2), sizeof(shell.args.password));
4✔
349
        strcpy(argv[i], "-p");
4✔
350
      }
351
    }
352
  }
353
  if (strlen(shell.args.password) == 0) {
1,131✔
354
    tstrncpy(shell.args.password, TSDB_DEFAULT_PASS, sizeof(shell.args.password));
1,127✔
355
  }
356

357
  SShellArgs *pArgs = &shell.args;
1,131✔
358
  pArgs->user = TSDB_DEFAULT_USER;
1,131✔
359
  pArgs->pktLen = SHELL_DEF_PKG_LEN;
1,131✔
360
  pArgs->pktNum = SHELL_DEF_PKG_NUM;
1,131✔
361
  pArgs->displayWidth = SHELL_DEFAULT_MAX_BINARY_DISPLAY_WIDTH;
1,131✔
362
}
1,131✔
363

364
static int32_t shellCheckArgs() {
1,111✔
365
  SShellArgs *pArgs = &shell.args;
1,111✔
366
  if (pArgs->host != NULL && (strlen(pArgs->host) <= 0 || strlen(pArgs->host) > TSDB_FQDN_LEN)) {
1,111!
367
    printf("Invalid host:%s\r\n", pArgs->host);
×
368
    return -1;
×
369
  }
370

371
  if (pArgs->user != NULL && (strlen(pArgs->user) <= 0 || strlen(pArgs->user) > TSDB_USER_LEN)) {
1,111!
372
    printf("Invalid user:%s\r\n", pArgs->user);
×
373
    return -1;
×
374
  }
375

376
  if (pArgs->auth != NULL && (strlen(pArgs->auth) <= 0 || strlen(pArgs->auth) > TSDB_PASSWORD_LEN)) {
1,111!
377
    printf("Invalid auth:%s\r\n", pArgs->auth);
×
378
    return -1;
×
379
  }
380

381
  if (pArgs->database != NULL && (strlen(pArgs->database) <= 0 || strlen(pArgs->database) > TSDB_DB_NAME_LEN)) {
1,111!
382
    printf("Invalid database:%s\r\n", pArgs->database);
×
383
    return -1;
×
384
  }
385

386
  if (pArgs->file[0] != 0) {
1,111✔
387
    char fullname[PATH_MAX] = {0};
851✔
388
    if (taosExpandDir(pArgs->file, fullname, PATH_MAX) == 0) {
851!
389
      tstrncpy(pArgs->file, fullname, PATH_MAX);
851✔
390
    }
391
  }
392

393
  if (pArgs->cfgdir != NULL) {
1,111✔
394
    if (strlen(pArgs->cfgdir) <= 0 || strlen(pArgs->cfgdir) >= PATH_MAX) {
146!
395
      printf("Invalid cfgdir:%s\r\n", pArgs->cfgdir);
×
396
      return -1;
×
397
    } else {
398
      if (taosExpandDir(pArgs->cfgdir, configDir, PATH_MAX) != 0) {
146!
399
        tstrncpy(configDir, pArgs->cfgdir, PATH_MAX);
×
400
      }
401
    }
402
  }
403

404
  if (pArgs->commands != NULL && (strlen(pArgs->commands) <= 0)) {
1,111!
405
    printf("Invalid commands:%s\r\n", pArgs->commands);
×
406
    return -1;
×
407
  }
408

409
  if (pArgs->netrole != NULL && !(strcmp(pArgs->netrole, "client") == 0 || strcmp(pArgs->netrole, "server") == 0)) {
1,111!
410
    printf("Invalid netrole:%s\r\n", pArgs->netrole);
×
411
    return -1;
×
412
  }
413

414
  if (/*pArgs->password != NULL && */ (strlen(pArgs->password) <= 0)) {
1,111!
415
    printf("Invalid password\r\n");
×
416
    return -1;
×
417
  }
418

419
  if (pArgs->port < 0 || pArgs->port > 65535) {
1,111!
420
    printf("Invalid port\r\n");
2✔
421
    return -1;
2✔
422
  }
423

424
  if (pArgs->pktLen < SHELL_MIN_PKG_LEN || pArgs->pktLen > SHELL_MAX_PKG_LEN) {
1,109!
425
    printf("Invalid pktLen:%d, range:[%d, %d]\r\n", pArgs->pktLen, SHELL_MIN_PKG_LEN, SHELL_MAX_PKG_LEN);
×
426
    return -1;
×
427
  }
428

429
  if (pArgs->pktNum < SHELL_MIN_PKG_NUM || pArgs->pktNum > SHELL_MAX_PKG_NUM) {
1,109!
430
    printf("Invalid pktNum:%d, range:[%d, %d]\r\n", pArgs->pktNum, SHELL_MIN_PKG_NUM, SHELL_MAX_PKG_NUM);
×
431
    return -1;
×
432
  }
433

434
  if (pArgs->displayWidth <= 0 || pArgs->displayWidth > 10 * 1024) {
1,109!
435
    printf("Invalid displayWidth:%d, range:[1, 10 * 1024]\r\n", pArgs->displayWidth);
×
436
    return -1;
×
437
  }
438

439
  return 0;
1,109✔
440
}
441

442
int32_t shellParseArgs(int32_t argc, char *argv[]) {
1,131✔
443
  shellInitArgs(argc, argv);
1,131✔
444
  shell.info.clientVersion =
1,131✔
445
      "Welcome to the %s Command Line Interface, Client Version:%s\r\n"
446
      "Copyright (c) 2023 by %s, all rights reserved.\r\n\r\n";
447
#ifdef CUS_NAME
448
  strcpy(shell.info.cusName, CUS_NAME);
1,131✔
449
#else
450
  strcpy(shell.info.cusName, "TDengine");
451
#endif
452
  char promptContinueFormat[32] = {0};
1,131✔
453
#ifdef CUS_PROMPT
454
  sprintf(shell.info.promptHeader, "%s> ", CUS_PROMPT);
1,131✔
455
  sprintf(promptContinueFormat, "%%%zus> ", strlen(CUS_PROMPT));
1,131✔
456
#else
457
  sprintf(shell.info.promptHeader, "taos> ");
458
  sprintf(promptContinueFormat, "%%%zus> ", strlen("taos"));
459
#endif
460
  sprintf(shell.info.promptContinue, promptContinueFormat, " ");
1,131✔
461
  shell.info.promptSize = strlen(shell.info.promptHeader);
1,131✔
462
#ifdef TD_ENTERPRISE
463
  snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),
1,131✔
464
           "%s\n%s version: %s compatible_version: %s\ngit: %s\ngitOfInternal: %s\nbuild: %s", TD_PRODUCT_NAME,
465
           CUS_PROMPT, td_version, td_compatible_version, td_gitinfo, td_gitinfoOfInternal, td_buildinfo);
466
#else
467
  snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),
468
           "%s\n%s version: %s compatible_version: %s\ngit: %s\nbuild: %s", TD_PRODUCT_NAME, CUS_PROMPT, td_version,
469
           td_compatible_version, td_gitinfo, td_buildinfo);
470
#endif
471

472
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
473
  shell.info.osname = "Windows";
474
  snprintf(shell.history.file, TSDB_FILENAME_LEN, "C:/TDengine/%s", SHELL_HISTORY_FILE);
475
  if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1;
476
#elif defined(_TD_DARWIN_64)
477
  shell.info.osname = "Darwin";
478
  snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getpwuid(getuid())->pw_dir, SHELL_HISTORY_FILE);
479
  if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1;
480
#else
481
  shell.info.osname = "Linux";
1,131✔
482
  snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getenv("HOME"), SHELL_HISTORY_FILE);
1,131✔
483
  shellParseArgsUseArgp(argc, argv);
1,131✔
484
  // if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1;
485
  if (shell.args.abort) {
1,111!
486
    return -1;
×
487
  }
488
#endif
489

490
  return shellCheckArgs();
1,111✔
491
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc