diff options
author | Michael Vogt <mvo@debian.org> | 2013-10-22 16:53:32 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-10-22 16:53:32 +0200 |
commit | f62f17b489405432a3125e51471d8a00e78c5170 (patch) | |
tree | ce2a6e077cb0846e75cbb3d583f4152608100adb /cmdline/apt-cdrom.cc | |
parent | 9aa9db9c88fca3a9266427b0d5cc9ad53df7207e (diff) | |
parent | c08cf1dc784a98a253296a51433f6de7d16d3125 (diff) |
Merge branch 'debian/sid' into ubuntu/master
Conflicts:
cmdline/apt-key
configure.ac
debian/apt.auto-removal.sh
debian/changelog
debian/control
debian/rules
po/apt-all.pot
po/ar.po
po/ast.po
po/bg.po
po/bs.po
po/ca.po
po/cs.po
po/cy.po
po/da.po
po/de.po
po/dz.po
po/el.po
po/es.po
po/eu.po
po/fi.po
po/fr.po
po/gl.po
po/hu.po
po/it.po
po/ja.po
po/km.po
po/ko.po
po/ku.po
po/lt.po
po/mr.po
po/nb.po
po/ne.po
po/nl.po
po/nn.po
po/pl.po
po/pt.po
po/pt_BR.po
po/ro.po
po/ru.po
po/sk.po
po/sl.po
po/sv.po
po/th.po
po/tl.po
po/uk.po
po/vi.po
po/zh_CN.po
po/zh_TW.po
Diffstat (limited to 'cmdline/apt-cdrom.cc')
-rw-r--r-- | cmdline/apt-cdrom.cc | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index c153cca85..17a60ddcb 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -37,6 +37,8 @@ #include <unistd.h> #include <stdio.h> +#include <apt-private/private-cmndline.h> + #include <apti18n.h> /*}}}*/ static const char *W_NO_CDROM_FOUND = \ @@ -66,7 +68,9 @@ void pkgCdromTextStatus::Prompt(const char *Text) { char C; cout << Text << ' ' << flush; - read(STDIN_FILENO,&C,1); + if (read(STDIN_FILENO,&C,1) < 0) + _error->Errno("pkgCdromTextStatus::Prompt", + "Failed to read from standard input (not a terminal?)"); if (C != '\n') cout << endl; } @@ -201,12 +205,12 @@ bool DoIdent(CommandLine &) // ShowHelp - Show the help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -int ShowHelp() +bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); if (_config->FindB("version") == true) - return 0; + return true; cout << "Usage: apt-cdrom [options] command\n" @@ -230,37 +234,25 @@ int ShowHelp() " -c=? Read this configuration file\n" " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n" "See fstab(5)\n"; - return 0; + return true; } /*}}}*/ int main(int argc,const char *argv[]) /*{{{*/ { - CommandLine::Args Args[] = { - {'h',"help","help",0}, - { 0,"auto-detect","Acquire::cdrom::AutoDetect", CommandLine::Boolean}, - {'v',"version","version",0}, - {'d',"cdrom","Acquire::cdrom::mount",CommandLine::HasArg}, - {'r',"rename","APT::CDROM::Rename",0}, - {'m',"no-mount","APT::CDROM::NoMount",0}, - {'f',"fast","APT::CDROM::Fast",0}, - {'n',"just-print","APT::CDROM::NoAct",0}, - {'n',"recon","APT::CDROM::NoAct",0}, - {'n',"no-act","APT::CDROM::NoAct",0}, - {'a',"thorough","APT::CDROM::Thorough",0}, - {'c',"config-file",0,CommandLine::ConfigFile}, - {'o',"option",0,CommandLine::ArbItem}, - {0,0,0,0}}; CommandLine::Dispatch Cmds[] = { {"add",&DoAdd}, {"ident",&DoIdent}, + {"help",&ShowHelp}, {0,0}}; + std::vector<CommandLine::Args> Args = getCommandArgs("apt-cdrom", CommandLine::GetCommand(Cmds, argc, argv)); + // Set up gettext support setlocale(LC_ALL,""); textdomain(PACKAGE); // Parse the command line and initialize the package library - CommandLine CmdL(Args,_config); + CommandLine CmdL(Args.data(),_config); if (pkgInitConfig(*_config) == false || CmdL.Parse(argc,argv) == false || pkgInitSystem(*_config,_system) == false) @@ -272,7 +264,7 @@ int main(int argc,const char *argv[]) /*{{{*/ // See if the help should be shown if (_config->FindB("help") == true || _config->FindB("version") == true || CmdL.FileSize() == 0) - return ShowHelp(); + return ShowHelp(CmdL); // Deal with stdout not being a tty if (isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) |