From patchwork Sun Nov 21 01:50:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fredrick Brennan X-Patchwork-Id: 1987 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [2a01:4f9:c010:3052::1] by patchwork.archlinux.org with IMAP (fetchmail-6.4.23) for (single-drop); Sun, 21 Nov 2021 01:50:42 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id eA0JCPKlmWGBvQgAK+/4rw (envelope-from ) for ; Sun, 21 Nov 2021 01:50:42 +0000 Received: from lists.archlinux.org (lists.archlinux.org [95.217.236.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 03202AA2492; Sun, 21 Nov 2021 01:50:39 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id B94469D2F92; Sun, 21 Nov 2021 01:50:39 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from sender4-op-o12.zoho.com (sender4-op-o12.zoho.com [136.143.188.12]) by lists.archlinux.org (Postfix) with ESMTPS id 8E7049D2F7D for ; Sun, 21 Nov 2021 01:50:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1637459432; cv=none; d=zohomail.com; s=zohoarc; b=fxhqoUEU+ANLL35OIw0BVQnLd1egFrl9eGacuwihQz/Hxa9pGVokJ8D2ozvXfQPNHVcf8XNS9mJ+QyJNVSD0boGVCLGi67bd1/f6/TVhtinhhY1wP+ZZSxwEDKuoTZH01iTIxpg0iYk7TgR/aJVrfmRY9gl3awzgtgR48cLLVI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637459432; h=Content-Type:Date:From:MIME-Version:Message-ID:Subject:To; bh=lie6vkR1BDn6QwJg/0v9hTGLBaSdC+twjpyY/O0PRAQ=; b=CVXAYV7N3DYiVqvOZiTN80bZNZ3MHzoSieADI0zdoM7Yel+yzJQyWomIw9EQFwUsZ/PTfxSdlIviCynbZMq0SAWcwTlysO9MRd/woxmS31dHFD7aqYfEaGJ8V4NRNTLftzs8ihyfsXtNOBK7NB4u81KpV+MhevzS+0qgri23Hh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=kittens.ph; spf=pass smtp.mailfrom=copypaste@kittens.ph; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1637459432; s=zoho; d=kittens.ph; i=copypaste@kittens.ph; h=Content-Type:Message-ID:Date:MIME-Version:From:Subject:To; bh=lie6vkR1BDn6QwJg/0v9hTGLBaSdC+twjpyY/O0PRAQ=; b=YiWxS3rhrw46oCuUkk8dzQCN1iN19atm+CgzRpAvH60EBu5AEhWcaLbImBUsiA8N NCDFVHbEJp33DIcOTCBT+JVy4kpmM1GrxILLOKWzG6mfUi5ByRLf+jk0LV9+fOXREPo HNyriSJWt9SEx0kSSjcwrcYM854VaLG+iq9RbAqo= Received: from [10.0.0.169] (c-69-248-31-251.hsd1.nj.comcast.net [69.248.31.251]) by mx.zohomail.com with SMTPS id 1637459430665614.4838775475345; Sat, 20 Nov 2021 17:50:30 -0800 (PST) Message-ID: <04781d57-77ce-2530-cee7-9a13c8301332@kittens.ph> Date: Sat, 20 Nov 2021 20:50:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 From: Fredrick Brennan Subject: =?utf-8?b?W1BBVENIXSBQZXJtaXQgYC0tc2VhcmNoPeKApmAgaW4gYC1RYCBhbmQg?= =?utf-8?b?YC1TYCB0byBhbGxvdyBmb3IgZS5nLiBgLS1zZWFyY2g9LWRvY2A=?= To: pacman-dev@lists.archlinux.org Content-Language: en-US X-Zoho-Virus-Status: 1 X-ZohoMailClient: External X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.35 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=kittens.ph header.s=zoho header.b=YiWxS3rh; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 95.217.236.249 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 03202AA2492 X-Spamd-Result: default: False [-1.31 / 15.00]; ARC_ALLOW(-1.00)[zohomail.com:s=zohoarc:i=1]; MIME_BASE64_TEXT_BOGUS(1.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; RCVD_IN_DNSWL_MED(-0.20)[95.217.236.249:from]; R_DKIM_ALLOW(-0.20)[kittens.ph:s=zoho]; MAILLIST(-0.20)[mailman]; R_SPF_ALLOW(-0.20)[+ip4:95.217.236.249]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; MIME_BASE64_TEXT(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; RCVD_IN_DNSWL_NONE(0.00)[136.143.188.12:received]; DMARC_NA(0.00)[kittens.ph]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:24940, ipnet:95.217.0.0/16, country:DE]; NEURAL_HAM(-0.00)[-1.000]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_NONE(0.00)[]; HAS_ATTACHMENT(0.00)[]; FROM_NEQ_ENVFROM(0.00)[copypaste@kittens.ph,pacman-dev-bounces@lists.archlinux.org]; DKIM_TRACE(0.00)[kittens.ph:+]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; RECEIVED_SPAMHAUS_PBL(0.00)[69.248.31.251:received]; RCVD_TLS_LAST(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org Greetings pacman-dev: Currently, pacman does not allow one to run `pacman -S --search=-doc`, because despite documentation saying `--search` takes ``, actually it is implemented as using the targets to determine what to search for. It is quite difficult to figure out how to carry out this search query, and needlessly so, though `--search '\\-doc'` does work. The cumulative effect of the two attached patches fixes it, allowing an easier way to search for arbitrary strings which may conflict with command line options. From 04aa99ea014f5c52bb59070c63c3989d17e35388 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Fri, 19 Nov 2021 16:10:51 -0500 Subject: [PATCH 2/2] =?UTF-8?q?Permit=20`--search=3D=E2=80=A6`=20in=20`-Q`?= =?UTF-8?q?=20and=20`-S`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows for e.g. `pacman -S --search=-doc`, right now difficult to discover how to do (`pacman -S --search '\\-doc'`) Signed-off-by: Fredrick Brennan --- src/pacman/pacman.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index ed2d19b2..ee575602 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -563,6 +563,8 @@ static int parsearg_query(int opt) case OP_SEARCH: case 's': config->op_q_search = 1; + if (optarg != NULL) + parsearg_util_addlist(&(pm_targets)); break; case OP_UNREQUIRED: case 't': @@ -605,6 +607,10 @@ static void checkargs_query(int parse_err) invalid_opt(config->op_q_owns, "--search", "--owns"); checkargs_query_display_opts("--search"); checkargs_query_filter_opts("--search"); + if (alpm_list_count(pm_targets) == 0 && parse_err) { + pm_printf(ALPM_LOG_ERROR, "No targets and --search, did you mean to use --search=…?"); + cleanup(1); + } } else if(config->op_q_owns) { invalid_opt(config->group, "--owns", "--groups"); checkargs_query_display_opts("--owns"); @@ -823,6 +829,8 @@ static int parsearg_sync(int opt) case OP_SEARCH: case 's': config->op_s_search = 1; + if (optarg != NULL) + parsearg_util_addlist(&(pm_targets)); break; case OP_SYSUPGRADE: case 'u': @@ -860,6 +868,10 @@ static void checkargs_sync(int parse_err) invalid_opt(config->op_q_list, "--search", "--list"); invalid_opt(config->op_s_upgrade, "--search", "--sysupgrade"); invalid_opt(config->op_s_downloadonly, "--search", "--downloadonly"); + if (alpm_list_count(pm_targets) == 0 && parse_err) { + pm_printf(ALPM_LOG_ERROR, "No targets and --search, did you mean to use --search=…?"); + cleanup(1); + } } else if(config->op_q_list) { invalid_opt(config->group, "--list", "--groups"); invalid_opt(config->op_s_upgrade, "--list", "--sysupgrade"); @@ -914,7 +926,7 @@ static int parseargs(int argc, char *argv[]) {"root", required_argument, 0, OP_ROOT}, {"sysroot", required_argument, 0, OP_SYSROOT}, {"recursive", no_argument, 0, OP_RECURSIVE}, - {"search", no_argument, 0, OP_SEARCH}, + {"search", optional_argument, 0, OP_SEARCH}, {"regex", no_argument, 0, OP_REGEX}, {"machinereadable", no_argument, 0, OP_MACHINEREADABLE}, {"unrequired", no_argument, 0, OP_UNREQUIRED}, -- 2.34.0