diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-06-12 18:19:47 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-06-20 17:05:39 +0800 |
commit | a88745bf22c3e83e5d78331a69f813e451c895a0 (patch) | |
tree | 008c6aeab03af51d680802401cbf3938980b0425 /src/cmdline/cmdline_prompt.cc | |
parent | d082e98fcf8d2809fd89d3bc2c3002f5e2e1f5a3 (diff) | |
download | aptitude-a88745bf22c3e83e5d78331a69f813e451c895a0.tar.gz |
Tidy error handling in main, cmdline actions
Error conditions are much stricter, detecting errors is more
reliable, and the exit status of all command-line actions is
well-defined.
All commands will return one of these values as their exit
status:
0 – success
1 – user aborted (install, remove, …); or
no matches (search, why, why-not);
100 – failure
For commands whose arguments are lists of packages or search
patterns the following general conditions hold:
It is a failure if any package argument does not exactly
name a package.
It is a failure if any versioned argument requests a
version which is not available for every package
identified by that argument. Versioned arguments are
those which end with a version or archive (release)
specifier, respectively “=<version>” and “/<archive>”.
If a command includes a request to install, remove, or
purge any package that command will not proceed if any
of the above failures occur. Other commands may still
proceed in case of such failures but will exit with
non-zero status to indicate they were not completely
effective.
Some commands have exceptions and/or extensions to the
general conditions:
install, upgrade, remove, …:
Where a request specifies a virtual package it is a
failure if it has either no provider or multiple
providers. If there is only one provider that package
will be selected instead of the virtual package.
search:
All arguments are considered patterns. Arguments
without an explicit search term will be wrapped in an
implicit ‘?name’ term.
This is a major change from previous versions where the
program would have proceeded and possibly exited with a
status indicating success (0) despite some requested actions
being either invalid or ineffective. The new, stricter
behaviour is desirable for two reasons:
- to prevent the situation where a request to replace one
set of packages with another set proceeds when (some of)
the replacements are not found or unavailable could cause
the undesired removal of arbitrary other packages;
- to make the program more atomic and reliable when used for
automated tasks – by considering the entire request as
being essential to success another program can rely on an
exit status of 0 to mean that the request was completely
carried out.
Summary of changes:
* Most errors are now displayed at the end of a command's
output which makes them easier to spot when there is
lots of output. (Closes: #430392)
* [cmdline]: Virtual packages which have an already
installed provider are only skipped when the
requested action is to install them.
* [cmdline]: install and similar actions have much
stronger error checking and will exit more
reliably with non-zero status on failures
Failures which result in no action and a
non-zero exit status (100):
- a package argument does not exactly name
an available package;
- a versioned argument requests a version
which is not available for every package
it applies to (Closes: #590686);
* [cmdline]: changelog exits with non-zero status on any
error (Closes: #675833)
* [cmdline]: search exit with status 1 if it found no
matches (Closes: #497299)
* [cmdline]: why exits with status 1 if it found no
reasons given the particular arguments
* [cmdline]: show will exit with status 100 if it found
no packages or a named package was not found
* unknown arguments do not show the usage screen
* more errors are reported using GlobalError
* clean up some strings used as error messages
* download_install_manager.cc:
- repeat if package manager result is DoAgain;
- report all download errors not just the first;
* cmdline_util.cc:
- pkgset_from_string by default is no longer an error if
a pattern matches no packages
* [doc]: add section on exit status to the man page
Closes: #430392
Closes: #497299
Closes: #590686
Closes: #675833
Diffstat (limited to 'src/cmdline/cmdline_prompt.cc')
-rw-r--r-- | src/cmdline/cmdline_prompt.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cmdline/cmdline_prompt.cc b/src/cmdline/cmdline_prompt.cc index 25fadaa7..150c98fb 100644 --- a/src/cmdline/cmdline_prompt.cc +++ b/src/cmdline/cmdline_prompt.cc @@ -475,7 +475,10 @@ static bool prompt_essential(const shared_ptr<terminal_metrics> &term_metrics) if(!ok) { - printf(_("WARNING: Performing this action will probably cause your system to break!\n Do NOT continue unless you know EXACTLY what you are doing!\n")); + printf(_("WARNING: Performing this action will probably cause your" + " system to break!\n" + " Do NOT continue unless you know EXACTLY what you" + " are doing!\n")); string untranslated_prompt = N_("I am aware that this is a very bad idea"); string prompt = _(untranslated_prompt.c_str()); @@ -739,8 +742,8 @@ bool cmdline_show_preview(bool as_upgrade, pkgset &to_install, printf(_("Need to get %sB of archives. "), SizeToStr(f.DebBytes).c_str()); } - else - _error->DumpErrors(); + // else + // _error->DumpErrors(); if((*apt_cache_file)->UsrSize() >=0) printf(_("After unpacking %sB will be used.\n"), |