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.
This commit is contained in:
Scott Kostyshak 2013-03-28 03:07:45 -04:00
parent cc138f6e68
commit 6df4a7bb40

View File

@ -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;