Kayvan A. Sylvan wrote:

> Latest CVS:
> 
> $ lyx --export foo

Ah yes... correct behaviour, but somewhat harsh wording ;-)

Anyway, It's entirely my fault (two different bugs actually).

Can I apply this fix?


Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.155
diff -u -p -u -r1.155 lyx_main.C
--- src/lyx_main.C      7 Jul 2003 08:36:58 -0000       1.155
+++ src/lyx_main.C      17 Jul 2003 22:01:00 -0000
@@ -142,6 +142,7 @@ LyX::LyX(int & argc, char * argv[])
 
        // Execute batch commands if available
        if (!batch_command.empty()) {
+
                lyxerr[Debug::INIT] << "About to handle -x '"
                       << batch_command << '\'' << endl;
 
@@ -155,25 +156,28 @@ LyX::LyX(int & argc, char * argv[])
                        // the filename if necessary
                        string s = FileSearch(string(), *it, "lyx");
                        if (s.empty()) {
-                               s = *it;
+                               last_loaded = newFile(*it, "");
+                       } else {
+                               last_loaded = bufferlist.newBuffer(s, false);
+                               
last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
+                               if (!loadLyXFile(last_loaded, s)) {
+                                       bufferlist.release(last_loaded);
+                                       last_loaded = newFile(*it, "");
+                               }
                        }
-
-                       last_loaded = bufferlist.newBuffer(s, false);
-                       last_loaded->error.connect(boost::bind(&LyX::printError, this, 
_1));
-                       loadLyXFile(last_loaded, s);
                }
 
-               files.clear();
-
                bool success = false;
 
                // try to dispatch to last loaded buffer first
-               bool const dispatched = last_loaded->dispatch(batch_command, &success);
+               if (last_loaded)
+                       last_loaded->dispatch(batch_command, &success);
+               else
+                       lyxerr << _("batch command specified but no "
+                                   "file could be loaded. Exiting.") << endl;
 
-               if (dispatched) {
-                       QuitLyX();
-                       exit(!success);
-               }
+               QuitLyX();
+               exit(!success);
        }
 
        lyx_gui::start(batch_command, files);

Reply via email to