Index: main.cpp =================================================================== --- main.cpp (revision 48986) +++ main.cpp (working copy) @@ -74,6 +74,11 @@ // object what ir needs to do: // bool list_mode = false; + // + // Only deal with an argument when we know if it's the last one. + // + char const* previous_argument = 0; + for(int i = 1; i < argc; ++i) { if(0 == std::strcmp("-h", argv[i]) @@ -138,12 +143,17 @@ } else { - if(!list_mode && (i == argc - 1)) - papp->set_destination(argv[i]); - else - papp->add_module(argv[i]); + if(previous_argument) + papp->add_module(previous_argument); + previous_argument = argv[i]; } } + if(previous_argument) { + if(!list_mode) + papp->set_destination(previous_argument); + else + papp->add_module(previous_argument); + } // // run the application object: //