]> git.saurik.com Git - apt.git/commitdiff
add syntax check for sources.list
authorMichael Vogt <mvo@debian.org>
Tue, 26 Nov 2013 08:22:40 +0000 (09:22 +0100)
committerMichael Vogt <mvo@debian.org>
Tue, 26 Nov 2013 08:22:40 +0000 (09:22 +0100)
cmdline/apt.cc

index ef31d002934f162b65a30e47fe7c5c2eb2362028..38610e7313df6b6ebc5209f734ce1e424c836923 100644 (file)
@@ -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;
 }