From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DEE3E1F406; Sun, 12 Nov 2023 09:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1699779769; bh=skVXDVmtBay8dU9687N+Vn+k8eR6A5K9hoBfEF7lCUo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=5omZGjWW3Q8r762y7TyU0VjmifiYL2B87i68rd+YlmlRYyXZM6SBjVzInTSzT//Sl qy7DJD8uoojKpc0XnL4ym9w2KC2El8v0KF6wzLB5eRyUZYIWOK+5QeFpTpKVc31x+7 HH+wgLJqyc3q+SHZXNcPsGOxhDvU3tuWAPC4b1oo= Date: Sun, 12 Nov 2023 09:02:49 +0000 From: Eric Wong To: Henrik Grimler Cc: meta@public-inbox.org Subject: Re: [Bug] lei: extra quotes inserted into query with AND/OR Message-ID: <20231112090249.M736442@dcvr> References: <20231111224411.GA620644@grimlerstat.localdomain> <20231112001050.M917867@dcvr> <20231112082356.GA3149@grimlerstat.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231112082356.GA3149@grimlerstat.localdomain> List-Id: Henrik Grimler wrote: > Hi Eric, > > On Sun, Nov 12, 2023 at 12:10:50AM +0000, Eric Wong wrote: > > Henrik Grimler wrote: > > > Hi, > > > > > > I recently found out about lei and installed it through archlinux's > > > package manager and am trying out queries. When using AND/OR extra > > > quotes are inserted in the curl command which messes it up, for > > > example: > > > > > > $ lei q -I https://lore.kernel.org/all/ -o ~/mail/foo 'dfn:COPYING OR dfn:Makefile' > > > # /home/grimler/.local/share/lei/store 0/0 > > > # /usr/bin/curl -Sf -s -d '' https://lore.kernel.org/all/?x=m&q=dfn%3A%22COPYING+OR+dfn%3AMakefile%22 > > > # 0 written to /home/grimler/mail/foo/ (0 matches) > > > > > > where it can be seen that it tries to search for 'dfn:"COPYING OR > > > dfn:Makefile"', and no hits are returned since there is no file named > > > "COPYING OR dfn:Makefile". > > > > Don't use quotes unless you want a phrase search. > > The quotes are added by lei (or some dependency) when query contains > space. Happens also if I search for a single file: > lei q -I https://lore.kernel.org/all/ -o ~/mail/foo ' dfn:COPYING' > which results in this curl cmd: > /usr/bin/curl -Sf -s -d '' https://lore.kernel.org/all/?x=m&q=+dfn%3A%22COPYING%22 > where %22 then is " Right, spaces require quotes in sh and lei inserts quotes when it sees spaces assuming it's a phrase search. Most queries involving filenames don't have spaces, and your original query shouldn't have spaces. It's 3 separate args in @argv of `lei_q': [ "dfn:COPYING", "OR", "dfn:Makefile" ] In other words, no quotes or spaces are needed in your case at all: $ lei q dfn:COPYING OR dfn:Makefile (I've omitted the -I and -o args for brevity) Your original query only passes 1 arg due to single or double quotes handled in the shell (assuming POSIX-like sh or bash): $ lei q 'dfn:COPYING OR dfn:Makefile' # don't do this $ lei q "dfn:COPYING OR dfn:Makefile" # don't do this, either In both cases the `lei_q' subroutine would only see [ "dfn:COPYING OR dfn:Makefile" ] in its @argv. If you have odd cases where you really need spaces in a single token and maybe not phrase search, --stdin can probably get what you want more reliably: $ echo 'dfn:"some filename with spaces" AND something.else' | lei q --stdin Hope that helps.