Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.1.0] Don't fall back to help command when command is empty #24970

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/cpp/option_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ std::unique_ptr<CommandLine> OptionProcessor::SplitCommandLine(
std::move(path_to_binary), std::move(startup_args), "", {}));
}
string& command = args[i];
// Distinguish an empty command from the case of no command above.
if (command.empty()) {
blaze_util::StringPrintf(error,
"Command cannot be the empty string.\n"
" For more info, run '%s help'.",
lowercase_product_name.c_str());
return nullptr;
}

// The rest are the command arguments.
vector<string> command_args(std::make_move_iterator(args.begin() + i + 1),
Expand Down
5 changes: 5 additions & 0 deletions src/test/shell/integration/client_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ function test_no_arguments() {
expect_log "Usage: b\\(laze\\|azel\\)"
}

function test_empty_command() {
bazel '' >&$TEST_log && fail "Expected non-zero exit"
expect_log "Command cannot be the empty string."
}

function test_local_startup_timeout() {
local output_base=$(bazel info output_base 2>"$TEST_log") ||
fail "bazel info failed"
Expand Down
Loading