On Sun, Oct 02, 2005 at 10:35:10AM +0200, Marc Haber wrote: > tags #217477 -fixed > found #217477 0.3.4-1 > thanks > > On Sat, Oct 01, 2005 at 04:47:07PM -0700, Daniel Burrows wrote: > > tag 217477 + fixed-in-experimental > > Unfortunately, this is not quite the case. > > * --quiet is not recognized at all. > > * -q syntax and semantics is incompatible with apt-get (which uses > -q=level instead of multiple -q options). This makes it hard to > write scripts which can work with apt-get and aptitude exchangeably. > * quiet behaves differently depending on whether output is redirected > or not:
Fixed with the attached patch in darcs. BTW, your second comment is inaccurate, at least according to the apt manual, in that apt-get should also accept multiple -q options. Daniel
Mon Oct 3 17:47:31 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]> * Accept --quiet=N and -q=N in the same manner as apt-get. (Closes: #217477) Mon Oct 3 17:47:08 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]> * Accept --quiet in addition to -q, as documented in the manual page. Mon Oct 3 16:44:19 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]> * Only increase the quiet level when stdout is not a tty. diff -rN -u old-head/doc/en/manpage.xml new-head/doc/en/manpage.xml --- old-head/doc/en/manpage.xml 2005-10-06 17:31:30.395676384 -0700 +++ new-head/doc/en/manpage.xml 2005-10-04 23:55:26.000000000 -0700 @@ -824,14 +824,26 @@ </varlistentry> <varlistentry> - <term><literal>-q</literal>, <literal>--quiet</literal></term> + <term><literal>-q<arg choice='opt'>=<replaceable>n</replaceable></arg></literal>, <literal>--quiet<arg choice='opt'>=<replaceable>n</replaceable></arg></literal></term> <listitem> - Suppress all incremental progress indicators, thus making - the output loggable. This may be supplied multiple times to - make the program quieter, but unlike &apt-get;, &aptitude; - does not enable <literal>-y</literal> when - <literal>-q</literal> is supplied more than once. + <para> + Suppress all incremental progress indicators, thus making + the output loggable. This may be supplied multiple times + to make the program quieter, but unlike &apt-get;, + &aptitude; does not enable <literal>-y</literal> when <literal>-q</literal> + is supplied more than once. + </para> + + + <para> + The optional <literal>=<replaceable>n</replaceable></literal> + may be used to directly set the amount of quietness (for + instance, to override a setting in <filename>/etc/apt/apt.conf</filename>); + it causes the program to behave as if <literal>-q</literal> + had been passed exactly <replaceable>n</replaceable> + times. + </para> </listitem> </varlistentry> diff -rN -u old-head/src/main.cc new-head/src/main.cc --- old-head/src/main.cc 2005-10-06 17:31:30.404675016 -0700 +++ new-head/src/main.cc 2005-10-04 23:55:26.000000000 -0700 @@ -173,6 +173,7 @@ {"help", 0, NULL, 'h'}, {"version", 0, &getopt_result, OPTION_VERSION}, {"display-format", 1, NULL, 'F'}, + {"quiet", 2, NULL, 'q'}, {"width", 1, NULL, 'w'}, {"simulate", 0, NULL, 's'}, {"with-recommends", 0, NULL, 'r'}, @@ -236,7 +237,7 @@ argv0=argv[0]; // Read the arguments: - while((curopt=getopt_long(argc, argv, "DVZvhS:uiF:w:sO:fdyPt:qRro:", opts, NULL))!=-1) + while((curopt=getopt_long(argc, argv, "DVZvhS:uiF:w:sO:fdyPt:q::Rro:", opts, NULL))!=-1) { switch(curopt) { @@ -274,7 +275,29 @@ assume_yes=true; break; case 'q': - ++quiet; + if(optarg == 0) + ++quiet; + else + { + if(*optarg == '=') + ++optarg; + + if(*optarg == 0) + { + fprintf(stderr, _("Expected a number after -q=\n")); + return -1; + } + + char *tmp; + quiet = strtol(optarg, &tmp, 0); + + if(*tmp != '\0') + { + fprintf(stderr, _("Expected a number after -q=, got %s\n"), + optarg); + return -1; + } + } seen_quiet = true; break; case 'r': @@ -349,7 +372,7 @@ } } - if(!isatty(1)) + if(quiet == 0 && !isatty(1)) aptcfg->SetNoUser("quiet", 1); else if(seen_quiet) aptcfg->SetNoUser("quiet", quiet);