On Wed, Jul 14, 2010 at 01:10:18AM +0200, Pavel Sanda wrote: > > core of my complaint was that changing semantics of traditional > switch is pita and will be hardly changed by disputing nitpicks > of selected examples inside coreutils.
Core of my answer was that switches of commands can be changed (despite this means breaking scripts) if they are wrong. > yep, i'm a perfect counter-example ;) although having much better knowledge > of the changes and the annoucement file itself then ordinary user it came out > of the blue. the news just state adding '-f' flag without any warn of > regression. Yes, this should have been said more clearly, admittedly. > could you elaborate why strong disagreement? another utils i'm currently using > around lyx work also like that - pdflatex rewrites ouput, dvips too. you are > strongly disagree with their doing also? > its really no fun to scan all the scripts in various projects manually > checking > usages of lyx calls and be worried what has been overlooked. so i would like > to hear that strong argument why we change this. Neither pdflatex, nor dvips will ever destroy your input file, would they? Instead, LyX can do that. Try "lyx -e lyx foo.lyx" and your input file will be overwritten, updated to the current version and your old input file is no more. > the user bug report was asking for slightly different thing - not overwriting > figure accompanying the lyx file. thats dataloss and needed to be fixed > indeed, > but overwriting .pdf result is completely different issue. So, we should check each format in order to decide what to do? If you have a gun, I suggest that you keep it discharged. Anyway, would the attached patch be enough for you? When you don't specify the -f switch, the preference settings are used when exporting from the command line. However, in order to keep the gun discharged, I added the "none" option for -f (I don't like living dangerously). -- Enrico
Index: src/LyX.cpp =================================================================== --- src/LyX.cpp (revisione 34892) +++ src/LyX.cpp (copia locale) @@ -91,9 +91,10 @@ bool use_gui = true; // Tell what files can be silently overwritten during batch export. -// Possible values are: NO_FILES, MAIN_FILE, ALL_FILES. +// Possible values are: NO_FILES, MAIN_FILE, ALL_FILES, USE_RC_PREF. +// Default is USE_RC_PREF, meaning that the RC preference will be used. -OverwriteFiles force_overwrite = NO_FILES; +OverwriteFiles force_overwrite = USE_RC_PREF; namespace { @@ -798,6 +799,10 @@ bool LyX::init() if (!lyxrc.path_prefix.empty()) prependEnvPath("PATH", lyxrc.path_prefix); + // If no -f switch was given, inherit the RC pref for overwriting files + if (force_overwrite == USE_RC_PREF) + force_overwrite = OverwriteFiles(lyxrc.export_overwrite); + FileName const document_path(lyxrc.document_path); if (document_path.exists() && document_path.isDirectory()) package().document_dir() = document_path; @@ -1126,6 +1131,9 @@ int parse_force(string const & arg, stri } else if (arg == "main") { force_overwrite = MAIN_FILE; return 1; + } else if (arg == "none") { + force_overwrite = NO_FILES; + return 1; } force_overwrite = ALL_FILES; return 0; Index: src/LyX.h =================================================================== --- src/LyX.h (revisione 34892) +++ src/LyX.h (copia locale) @@ -37,7 +37,8 @@ class SpellChecker; enum OverwriteFiles { NO_FILES, MAIN_FILE, - ALL_FILES + ALL_FILES, + USE_RC_PREF }; extern bool use_gui;