]> git.lyx.org Git - features.git/commitdiff
Exit with error if required filename is not given
authorScott Kostyshak <skostysh@lyx.org>
Fri, 29 Mar 2013 15:34:04 +0000 (11:34 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Sat, 30 Mar 2013 04:01:39 +0000 (00:01 -0400)
This is a second attempt to fix the problem described in
6df4a7bb (2c2c1767 reverted the first attempt).

The solution here is more general: if we get to a certain point
in the code and there is no filename, an error is given.

The following command now gives an error:

  lyx -e pdf2

And the following command continues to not give an error:

  lyx myfile.lyx -e pdf

src/LyX.cpp

index 2096be7a771d28256a275cea6bd272551c1e5929..55fb0711ad71f4ae4517edc6405dba86f3f24c51 100644 (file)
@@ -468,6 +468,11 @@ int LyX::init(int & argc, char * argv[])
        for (int argi = 1; argi < argc; ++argi)
                pimpl_->files_to_load_.push_back(os::utf8_argv(argi));
 
+       if (!use_gui && pimpl_->files_to_load_.empty()) {
+               lyxerr << to_utf8(_("Missing filename for this operation.")) << endl;
+               return EXIT_FAILURE;
+       }
+
        if (first_start) {
                pimpl_->files_to_load_.push_back(
                        i18nLibFileSearch("examples", "splash.lyx").absFileName());