Skip to content

Commit a1be8e0

Browse files
authored
Merge pull request #139 from knst/return-status
[FIX] Fix return value of main() if program failed
2 parents 58ff9b4 + c0fa7d0 commit a1be8e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

source/cppfront.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,15 +2665,16 @@ auto main(int argc, char* argv[]) -> int
26652665
cmdline.process_flags();
26662666

26672667
if (cmdline.help_was_requested()) {
2668-
return 0;
2668+
return EXIT_SUCCESS;
26692669
}
26702670

26712671
if (cmdline.arguments().empty()) {
26722672
std::cout << "cppfront: error: no input files\n";
2673-
return 0;
2673+
return EXIT_FAILURE;
26742674
}
26752675

26762676
// For each .cpp2 source file
2677+
int exit_status = EXIT_SUCCESS;
26772678
for (auto const& arg : cmdline.arguments())
26782679
{
26792680
std::cout << arg.text << "...";
@@ -2701,6 +2702,7 @@ auto main(int argc, char* argv[]) -> int
27012702
std::cout << "\n";
27022703
c.print_errors();
27032704
std::cout << "\n";
2705+
exit_status = EXIT_FAILURE;
27042706
}
27052707

27062708
// In any case, emit the debug information (during early development this is
@@ -2709,4 +2711,5 @@ auto main(int argc, char* argv[]) -> int
27092711
c.debug_print();
27102712
}
27112713
}
2714+
return exit_status;
27122715
}

0 commit comments

Comments
 (0)