From c3ded84c6f99bda4caf63c8662416ffb0189d31b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 16 Oct 2015 18:03:52 +0200 Subject: add binary-specific options via Binary scope Especially with apt now, it can be useful to set an option only for apt and not for apt-get. Using a binary-specific subtree which is merged into the root seems like a simple enough trick to achieve this. --- apt-private/private-cmndline.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'apt-private/private-cmndline.cc') diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 5d6fd3c2e..81352d757 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -322,8 +323,21 @@ void ParseCommandLine(CommandLine &CmdL, CommandLine::Dispatch * const Cmds, Com Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[], bool(*ShowHelp)(CommandLine &CmdL)) { CmdL = CommandLine(Args,_config); - if ((Cnf != NULL && pkgInitConfig(**Cnf) == false) || - CmdL.Parse(argc,argv) == false || + if (Cnf != NULL && pkgInitConfig(**Cnf) == false) + { + _error->DumpErrors(); + exit(100); + } + + if (likely(argc != 0 && argv[0] != NULL)) + { + std::string const binary = flNotDir(argv[0]); + _config->Set("Binary", binary); + std::string const conf = "Binary::" + binary; + _config->MoveSubTree(conf.c_str(), NULL); + } + + if (CmdL.Parse(argc,argv) == false || (Sys != NULL && pkgInitSystem(*_config, *Sys) == false)) { if (_config->FindB("version") == true) -- cgit v1.2.3