[pacman-dev] [PATCHv3 5/7] pacsearch: skip any non-matching line instead of printing them
Andrew Gregory
andrew.gregory.8 at gmail.com
Mon Feb 10 11:06:51 EST 2014
On 02/09/14 at 07:41pm, Pierre Neidhardt wrote:
> If input cannot be parsed, it is not desirable to output it along other valid
> entries. This would make pacsearch output unpredictable.
>
> Signed-off-by: Pierre Neidhardt <ambrevar at gmail.com>
> ---
> contrib/pacsearch.in | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
-1. pacsearch is a thin pacman wrapper and should not hide output.
Since it doesn't do any real argument parsing, a user can pass an
option that alters pacman's output (-q for instance) and this would
hide all output from the user without giving any indication of an
error.
> diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in
> index 0ab840e..df0d62d 100644
> --- a/contrib/pacsearch.in
> +++ b/contrib/pacsearch.in
> @@ -111,11 +111,8 @@ foreach $_ (@syncpkgs) {
> # desc. We grab leading space for 'group' and 'installed' so that we do not
> # need to test if non-empty when printing.
> my @pkgfields = /^(.*?)\/(.*?) (.*?)( \(.*?\))?( \[.*\])?\n(.*)$/s;
> - if(not @pkgfields) {
> - # skip any non-matching line and just print it for the user
> - print $_, "\n";
> - next;
> - }
> + # skip any non-matching line
> + next if not defined $pkgfields[1];
> # since 'group' and 'installed' are optional, we should fill it in if necessary
> $pkgfields[3] = "" if not defined $pkgfields[3];
> $pkgfields[4] = "" if not defined $pkgfields[4];
> --
> 1.8.5.4
More information about the pacman-dev
mailing list