summaryrefslogtreecommitdiff
path: root/cmdline/apt.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-11-26 09:22:40 +0100
committerMichael Vogt <mvo@debian.org>2013-11-26 09:22:40 +0100
commitd2524a53bbd219ee6d069006fd243a5bcda0245b (patch)
tree0cc4b2806d081e1abfab264cbb33a7fc4c4d7038 /cmdline/apt.cc
parentcfacba5230f2e6bb88a1949505843ac22ed342d5 (diff)
add syntax check for sources.list
Diffstat (limited to 'cmdline/apt.cc')
-rw-r--r--cmdline/apt.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index ef31d0029..38610e731 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -67,9 +67,22 @@ bool EditSources(CommandLine &CmdL)
// FIXME: take hash before,
// when changed display message to apt update
- // do syntax check after save (like visudo)
-
- EditFileInSensibleEditor(sourceslist);
+ bool res;
+ pkgSourceList sl;
+
+ do {
+ EditFileInSensibleEditor(sourceslist);
+ _error->PushToStack();
+ res = sl.Read(sourceslist);
+ if (!res) {
+ std::string outs;
+ strprintf(outs, _("Failed to parse %s. Edit again? "),
+ sourceslist.c_str());
+ std::cout << outs;
+ res = !YnPrompt(true);
+ }
+ _error->RevertToStack();
+ } while (res == false);
return true;
}