Message ID | 20200306021037.66811-1-jakseb.dev@gmail.com |
---|---|
State | Accepted, archived |
Headers | show |
Series | pactree: Improve command line validation | expand |
On March 5, 2020 9:10:37 PM EST, Sebastian Jakubiak <jakseb.dev@gmail.com> wrote: > Exit with non-zero status when the command line specifies more > than one package or an unknown option. > > Fixes FS#64589. > > Signed-off-by: Sebastian Jakubiak <jakseb.dev@gmail.com> > --- > > If I may, I would like to use this occasion to suggest a feature: the > ability to process multiple packages by pactree. I am sending a patch > for that in reply to this email. > > src/pactree.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/pactree.c b/src/pactree.c > index 5bc0032..9f074fe 100644 > --- a/src/pactree.c > +++ b/src/pactree.c > @@ -346,7 +346,6 @@ static int parse_options(int argc, char *argv[]) > version(); > cleanup(0); > case 'h': > - case '?': > usage(); > cleanup(0); > default: > @@ -355,7 +354,8 @@ static int parse_options(int argc, char *argv[]) > } > } > > - if(!argv[optind]) { > + if(!argv[optind] || argv[optind + 1]) { > + usage(); > return 1; > } > Pushed, thank you. -- Best, Daniel <https://danielcapella.com>
diff --git a/src/pactree.c b/src/pactree.c index 5bc0032..9f074fe 100644 --- a/src/pactree.c +++ b/src/pactree.c @@ -346,7 +346,6 @@ static int parse_options(int argc, char *argv[]) version(); cleanup(0); case 'h': - case '?': usage(); cleanup(0); default: @@ -355,7 +354,8 @@ static int parse_options(int argc, char *argv[]) } } - if(!argv[optind]) { + if(!argv[optind] || argv[optind + 1]) { + usage(); return 1; }
Exit with non-zero status when the command line specifies more than one package or an unknown option. Fixes FS#64589. Signed-off-by: Sebastian Jakubiak <jakseb.dev@gmail.com> --- If I may, I would like to use this occasion to suggest a feature: the ability to process multiple packages by pactree. I am sending a patch for that in reply to this email. src/pactree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)