MCPcopy Create free account
hub / github.com/duckdb/duckdb / RunShellCommand

Function RunShellCommand

tools/shell/shell_metadata_command.cpp:434–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434MetadataResult RunShellCommand(ShellState &state, const vector<string> &args) {
435 if (state.safe_mode) {
436 state.Print(PrintOutput::STDERR, ".sh/.system cannot be used in -safe mode\n");
437 return MetadataResult::FAIL;
438 }
439 int x;
440 if (args.size() < 2) {
441 return MetadataResult::PRINT_USAGE;
442 }
443 auto zCmd = StringUtil::Format(StringUtil::Contains(args[1], ' ') ? "%s" : "\"%s\"", args[1]);
444 for (idx_t i = 2; i < args.size(); i++) {
445 zCmd += StringUtil::Format(StringUtil::Contains(args[i], ' ') ? " %s" : " \"%s\"", args[i]);
446 }
447 x = system(zCmd.c_str());
448 if (x) {
449 state.PrintF(PrintOutput::STDERR, "System command returns %d\n", x);
450 }
451 return MetadataResult::SUCCESS;
452}
453
454MetadataResult ShowConfiguration(ShellState &state, const vector<string> &args) {
455 state.ShowConfiguration();

Callers

nothing calls this directly

Calls 5

ContainsFunction · 0.85
c_strMethod · 0.80
PrintMethod · 0.45
sizeMethod · 0.45
PrintFMethod · 0.45

Tested by

no test coverage detected