CmdHelp: Return error if man command fails

I feel this is expected behavior, but also eliminates the following compile time
warning on one of my systems:

  warning: ignoring return value of ‘int system(const char*)’, declared with
    attribute warn_unused_result [-Wunused-result]

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
This commit is contained in:
Shaun Ruffell 2020-02-23 23:52:30 -06:00 committed by lauft
parent 9ae84426d9
commit b5df2a2aa5
2 changed files with 3 additions and 3 deletions

View file

@ -117,8 +117,8 @@ int CmdHelp (
if (! words.empty ()) if (! words.empty ())
{ {
std::string man_command = "man timew-" + words[0]; std::string man_command = "man timew-" + words[0];
system (man_command.c_str()); int ret = system (man_command.c_str());
return 0; return (WIFEXITED (ret)) ? WEXITSTATUS (ret) : -1;
} }
return CmdHelpUsage (extensions); return CmdHelpUsage (extensions);

View file

@ -68,7 +68,7 @@ class TestHelp(TestCase):
def test_help_with_unknown_argument_should_show_error_message(self): def test_help_with_unknown_argument_should_show_error_message(self):
"""timew help with unknown argument should show error message""" """timew help with unknown argument should show error message"""
code, out, err = self.t("help bogus") code, out, err = self.t.runError("help bogus")
self.assertRegex(err, r"No manual entry for timew-bogus") self.assertRegex(err, r"No manual entry for timew-bogus")
def test_command_with_help_long_option_should_show_help_page(self): def test_command_with_help_long_option_should_show_help_page(self):