about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-26 15:59:03 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-26 16:58:54 -0700
commit87fe3d7a9e5ae9503ee89a3d69f8b84a88ad24de (patch)
treedcbd84449ecf20bb5698b4e28db194996196579c
parent4db6b370346d1a2fef2d35c1a64580e93e2bdf0d (diff)
downloadmu-87fe3d7a9e5ae9503ee89a3d69f8b84a88ad24de.tar.gz
4426 - error on unrecognized sub-commands
-rw-r--r--subx/000organization.cc4
-rw-r--r--subx/002test.cc9
-rw-r--r--subx/020elf.cc1
-rw-r--r--subx/021translate.cc1
4 files changed, 13 insertions, 2 deletions
diff --git a/subx/000organization.cc b/subx/000organization.cc
index a82fd67d..87004af5 100644
--- a/subx/000organization.cc
+++ b/subx/000organization.cc
@@ -122,7 +122,9 @@ int main(int argc, char* argv[]) {
   // Commandline Parsing
   // End Commandline Parsing
 
-  return 0;  // End Main
+  // End Main
+
+  return 0;
 }
 
 // Unit Tests
diff --git a/subx/002test.cc b/subx/002test.cc
index af6c34a3..f25e331f 100644
--- a/subx/002test.cc
+++ b/subx/002test.cc
@@ -13,7 +13,7 @@ typedef void (*test_fn)(void);
 :(before "Globals")
 // move a global ahead into types that we can't generate an extern declaration for
 const test_fn Tests[] = {
-  #include "test_list"  // auto-generated; see 'build' script
+  #include "test_list"  // auto-generated; see 'build*' scripts
 };
 
 :(before "End Globals")
@@ -70,6 +70,13 @@ if (Run_tests) {
   return 0;
 }
 
+:(after "End Main")
+//: Raise other unrecognized sub-commands as errors.
+//: We couldn't do this until now because we want `./subx test` to always
+//: succeed, no matter how many layers are included in the build.
+cerr << "nothing to do\n";
+return 1;
+
 :(code)
 void run_test(size_t i) {
   if (i >= sizeof(Tests)/sizeof(Tests[0])) {
diff --git a/subx/020elf.cc b/subx/020elf.cc
index 2f6e93f7..1939c1a7 100644
--- a/subx/020elf.cc
+++ b/subx/020elf.cc
@@ -14,6 +14,7 @@ if (is_equal(argv[1], "run")) {
   while (EIP < End_of_program)  // weak final-gasp termination check
     run_one_instruction();
   dbg << "executed past end of the world: " << EIP << " vs " << End_of_program << end();
+  return 0;
 }
 
 :(code)
diff --git a/subx/021translate.cc b/subx/021translate.cc
index 8289526b..a813cd4d 100644
--- a/subx/021translate.cc
+++ b/subx/021translate.cc
@@ -35,6 +35,7 @@ if (is_equal(argv[1], "translate")) {
   if (trace_contains_errors()) return 1;
   save_elf(p, argv[3]);
   if (trace_contains_errors()) unlink(argv[3]);
+  return 0;
 }
 
 :(code)