See attached patch.

Before, 'lyx -e pdf2' would give no error and would exit with 0. A use
case is if a user has in a bash script the following command:

lyx -e pdf2 "${mylxyfile}" || exit 1

where 'lyx' is mispelled as 'lxy' and thus yields an empty
string. If LyX does not exit with an error, the script continues where
the user probably intends for it to stop.

Can it go in?

Scott
From 32bd181a38ec04ba40931584633271ebf657660f Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Thu, 28 Mar 2013 03:07:45 -0400
Subject: [PATCH] Exit with error if no filename given to -e switch

Before, 'lyx -e pdf2' would give no error and would exit with 0. A use
case is if a user has in a bash script the following command:

lyx -e pdf2 "${mylxyfile}" || exit 1

where 'lyx' is mispelled as 'lxy' and thus yields an empty
string. If LyX does not exit with an error, the script continues where
the user probably intends for it to stop.
---
 src/LyX.cpp |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/LyX.cpp b/src/LyX.cpp
index e68ae03..b412033 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -1119,13 +1119,18 @@ int parse_export_to(string const & type, string const & 
output_file, string & ba
 }
 
 
-int parse_export(string const & type, string const &, string & batch)
+int parse_export(string const & type, string const & file, string & batch)
 {
        if (type.empty()) {
                lyxerr << to_utf8(_("Missing file type [eg latex, ps...] after "
                                         "--export switch")) << endl;
                exit(1);
        }
+       if (file.empty()) {
+               lyxerr << to_utf8(_("Missing filename after format")) << endl;
+               exit(1);
+       }
+
        batch = "buffer-export " + type;
        use_gui = false;
        return 1;
-- 
1.7.9.5

Reply via email to