[pacman-dev] [PATCH 1/7] pacman/util: remove strsplit
strsplit was used in only one place and did the same thing as strtok.
Signed-off-by: Andrew Gregory
Removes the overlap between optflags for different operations that
allowed non-sensical combinations of flags such as:
$ pacman -Si --changelog $package
--changelog is -c, meaning --clean for -S
$ pacman -Q --sysupgrade
--sysupgrade is -u, meaning --upgrades for -Q
Also add a few missing braces.
Original-work-by: Dave Reisner
On invalid combinations of flags we were only printing the unhelpfully
vague message "invalid option".
Signed-off-by: Andrew Gregory
On 13/10/13 03:32, Andrew Gregory wrote:
On invalid combinations of flags we were only printing the unhelpfully vague message "invalid option".
Signed-off-by: Andrew Gregory
--- src/pacman/conf.h | 3 ++- src/pacman/pacman.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pacman/conf.h b/src/pacman/conf.h index e263d7c..45e48c0 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -128,7 +128,8 @@ enum {
/* Long Operations */ enum { - OP_NOCONFIRM = 1000, + OP_LONG_FLAG_MIN = 1000, + OP_NOCONFIRM, OP_CONFIG, OP_IGNORE, OP_DEBUG, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 93baa44..308ff38 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -828,7 +828,12 @@ static int parseargs(int argc, char *argv[]) result = parsearg_global(opt); if(result != 0) { /* global option parsing failed, abort */ - pm_printf(ALPM_LOG_ERROR, _("invalid option\n")); + if(opt < OP_LONG_FLAG_MIN) { + pm_printf(ALPM_LOG_ERROR, _("invalid option '-%c'\n"), opt); + } else { + pm_printf(ALPM_LOG_ERROR, _("invalid option '--%s'\n"), + opts[option_index].name); + } return result;
I spent some time trying to get to this error. I found tow ways to get there and both do not seem like this is actually the right error message: allan@arya ~
pacman --color=foo error: invalid argument 'foo' for --color error: invalid option
allan@arya ~
pacman --debug=4 error: '4' is not a valid debug level error: invalid option
How else can we get there?
On 13/10/13 09:55, Allan McRae wrote:
On 13/10/13 03:32, Andrew Gregory wrote:
On invalid combinations of flags we were only printing the unhelpfully vague message "invalid option".
Signed-off-by: Andrew Gregory
--- src/pacman/conf.h | 3 ++- src/pacman/pacman.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pacman/conf.h b/src/pacman/conf.h index e263d7c..45e48c0 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -128,7 +128,8 @@ enum {
/* Long Operations */ enum { - OP_NOCONFIRM = 1000, + OP_LONG_FLAG_MIN = 1000, + OP_NOCONFIRM, OP_CONFIG, OP_IGNORE, OP_DEBUG, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 93baa44..308ff38 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -828,7 +828,12 @@ static int parseargs(int argc, char *argv[]) result = parsearg_global(opt); if(result != 0) { /* global option parsing failed, abort */ - pm_printf(ALPM_LOG_ERROR, _("invalid option\n")); + if(opt < OP_LONG_FLAG_MIN) { + pm_printf(ALPM_LOG_ERROR, _("invalid option '-%c'\n"), opt); + } else { + pm_printf(ALPM_LOG_ERROR, _("invalid option '--%s'\n"), + opts[option_index].name); + } return result;
I spent some time trying to get to this error. I found tow ways to get there and both do not seem like this is actually the right error message:
allan@arya ~
pacman --color=foo error: invalid argument 'foo' for --color error: invalid option
allan@arya ~
pacman --debug=4 error: '4' is not a valid debug level error: invalid option
How else can we get there?
Answering my own question:
pacman -S --changelog error: invalid option
On 10/13/13 at 09:55am, Allan McRae wrote:
On 13/10/13 03:32, Andrew Gregory wrote:
On invalid combinations of flags we were only printing the unhelpfully vague message "invalid option".
Signed-off-by: Andrew Gregory
--- src/pacman/conf.h | 3 ++- src/pacman/pacman.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pacman/conf.h b/src/pacman/conf.h index e263d7c..45e48c0 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -128,7 +128,8 @@ enum {
/* Long Operations */ enum { - OP_NOCONFIRM = 1000, + OP_LONG_FLAG_MIN = 1000, + OP_NOCONFIRM, OP_CONFIG, OP_IGNORE, OP_DEBUG, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 93baa44..308ff38 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -828,7 +828,12 @@ static int parseargs(int argc, char *argv[]) result = parsearg_global(opt); if(result != 0) { /* global option parsing failed, abort */ - pm_printf(ALPM_LOG_ERROR, _("invalid option\n")); + if(opt < OP_LONG_FLAG_MIN) { + pm_printf(ALPM_LOG_ERROR, _("invalid option '-%c'\n"), opt); + } else { + pm_printf(ALPM_LOG_ERROR, _("invalid option '--%s'\n"), + opts[option_index].name); + } return result;
I spent some time trying to get to this error. I found tow ways to get there and both do not seem like this is actually the right error message:
allan@arya ~
pacman --color=foo error: invalid argument 'foo' for --color error: invalid option
allan@arya ~
pacman --debug=4 error: '4' is not a valid debug level error: invalid option
How else can we get there?
Use a valid option with an operation that doesn't understand it such as `pacman -T --quiet`.
On 13/10/13 10:12, Andrew Gregory wrote:
On 10/13/13 at 09:55am, Allan McRae wrote:
On 13/10/13 03:32, Andrew Gregory wrote:
On invalid combinations of flags we were only printing the unhelpfully vague message "invalid option".
Signed-off-by: Andrew Gregory
--- src/pacman/conf.h | 3 ++- src/pacman/pacman.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pacman/conf.h b/src/pacman/conf.h index e263d7c..45e48c0 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -128,7 +128,8 @@ enum {
/* Long Operations */ enum { - OP_NOCONFIRM = 1000, + OP_LONG_FLAG_MIN = 1000, + OP_NOCONFIRM, OP_CONFIG, OP_IGNORE, OP_DEBUG, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 93baa44..308ff38 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -828,7 +828,12 @@ static int parseargs(int argc, char *argv[]) result = parsearg_global(opt); if(result != 0) { /* global option parsing failed, abort */ - pm_printf(ALPM_LOG_ERROR, _("invalid option\n")); + if(opt < OP_LONG_FLAG_MIN) { + pm_printf(ALPM_LOG_ERROR, _("invalid option '-%c'\n"), opt); + } else { + pm_printf(ALPM_LOG_ERROR, _("invalid option '--%s'\n"), + opts[option_index].name); + } return result;
I spent some time trying to get to this error. I found tow ways to get there and both do not seem like this is actually the right error message:
allan@arya ~
pacman --color=foo error: invalid argument 'foo' for --color error: invalid option
allan@arya ~
pacman --debug=4 error: '4' is not a valid debug level error: invalid option
How else can we get there?
Use a valid option with an operation that doesn't understand it such as `pacman -T --quiet`.
I like this patch, so accepted with the note that this output is bad (but was bad in the first place...) allan@arya /home/arch/code/pacman (working)
./src/pacman/pacman --color=foo error: invalid argument 'foo' for --color error: invalid option '--color'
--print-format is totally useless without --print. Implying --print
will also save us the hassle of checking it when we add transaction
option validation.
Signed-off-by: Andrew Gregory
PKG_LOCALITY_LOCAL was confusing because the enum is used with -Q, so
all packages are "local". Also reversed the config->op_q_locality
assignment so that the locality matches the option used.
Signed-off-by: Andrew Gregory
Fixes FS#20950
Signed-off-by: Andrew Gregory
Running an install script does not fall under "Adds/removes the database
entry only."
Signed-off-by: Andrew Gregory
participants (2)
-
Allan McRae
-
Andrew Gregory