pacman: use exit status 0 for --help and --version
The user requesting usage or version information is not an error. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
7ae25ac67f
commit
aabb7c3cdd
5 changed files with 13 additions and 6 deletions
|
@ -889,11 +889,11 @@ static int parseargs(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if(config->help) {
|
if(config->help) {
|
||||||
usage(config->op, mbasename(argv[0]));
|
usage(config->op, mbasename(argv[0]));
|
||||||
return 2;
|
cleanup(0);
|
||||||
}
|
}
|
||||||
if(config->version) {
|
if(config->version) {
|
||||||
version();
|
version();
|
||||||
return 2;
|
cleanup(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse all other options */
|
/* parse all other options */
|
||||||
|
|
|
@ -45,6 +45,7 @@ static struct options_t {
|
||||||
int sortkey;
|
int sortkey;
|
||||||
int null;
|
int null;
|
||||||
int filemode;
|
int filemode;
|
||||||
|
int help;
|
||||||
char delim;
|
char delim;
|
||||||
} opts;
|
} opts;
|
||||||
|
|
||||||
|
@ -374,7 +375,8 @@ static int parse_options(int argc, char **argv)
|
||||||
opts.filemode = 1;
|
opts.filemode = 1;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
return 1;
|
opts.help = 1;
|
||||||
|
return 0;
|
||||||
case 'k':
|
case 'k':
|
||||||
opts.sortkey = (int)strtol(optarg, NULL, 10);
|
opts.sortkey = (int)strtol(optarg, NULL, 10);
|
||||||
if(opts.sortkey <= 0) {
|
if(opts.sortkey <= 0) {
|
||||||
|
@ -420,6 +422,11 @@ int main(int argc, char *argv[])
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(opts.help) {
|
||||||
|
usage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
list = list_new(100);
|
list = list_new(100);
|
||||||
buffer = buffer_new(BUFSIZ * 3);
|
buffer = buffer_new(BUFSIZ * 3);
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,4 @@ self.description = "Test command line option (--version)"
|
||||||
|
|
||||||
self.args = "--version"
|
self.args = "--version"
|
||||||
|
|
||||||
self.addrule("PACMAN_RETCODE=2")
|
self.addrule("PACMAN_RETCODE=0")
|
||||||
|
|
|
@ -2,4 +2,4 @@ self.description = "Test command line option (--help)"
|
||||||
|
|
||||||
self.args = "--help"
|
self.args = "--help"
|
||||||
|
|
||||||
self.addrule("PACMAN_RETCODE=2")
|
self.addrule("PACMAN_RETCODE=0")
|
||||||
|
|
|
@ -2,4 +2,4 @@ self.description = "Test command line option (-S --help)"
|
||||||
|
|
||||||
self.args = "-S --help"
|
self.args = "-S --help"
|
||||||
|
|
||||||
self.addrule("PACMAN_RETCODE=2")
|
self.addrule("PACMAN_RETCODE=0")
|
||||||
|
|
Loading…
Add table
Reference in a new issue