From 9faed6a95b2d90df197d034dc20acdbe498011a1 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sat, 21 Oct 2023 19:58:22 -0700 Subject: [PATCH] phonebook: exit with appropriate code. --- src/bin/phonebook.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bin/phonebook.cc b/src/bin/phonebook.cc index f276b5f..5b46540 100644 --- a/src/bin/phonebook.cc +++ b/src/bin/phonebook.cc @@ -138,6 +138,7 @@ usage(ostream &os, int exc) int main(int argc, char *argv[]) { + int retc = 1; bool help = false; std::string fileName(pbFile); @@ -190,18 +191,24 @@ main(int argc, char *argv[]) switch (result) { case Subcommand::Status::OK: std::cout << "[+] OK\n"; + retc = 0; break; case Subcommand::Status::NotEnoughArgs: + delete flags; usage(cerr, 1); break; case Subcommand::Status::Failed: cerr << "[!] '"<< command << "' failed\n"; break; case Subcommand::Status::CommandNotRegistered: + delete flags; cerr << "[!] '" << command << "' not registered.\n"; usage(cerr, 1); break; default: + delete flags; abort(); } + + return retc; } \ No newline at end of file