From 6df4a7bb4018c7e13e191e59fdd5d9f768ce5592 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LyX.cpp b/src/LyX.cpp index ec522dead9..885e2bc302 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -1119,13 +1119,17 @@ 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; -- 2.39.2