From: Henrik Grimler <henrik@grimler.se>
To: Eric Wong <e@80x24.org>
Cc: meta@public-inbox.org
Subject: Re: [Bug] lei: extra quotes inserted into query with AND/OR
Date: Sun, 12 Nov 2023 12:59:16 +0100 [thread overview]
Message-ID: <20231112115916.GA6228@grimlerstat.localdomain> (raw)
In-Reply-To: <20231112090249.M736442@dcvr>
Hi Eric,
On Sun, Nov 12, 2023 at 09:02:49AM +0000, Eric Wong wrote:
> Henrik Grimler <henrik@grimler.se> wrote:
> > Hi Eric,
> >
> > On Sun, Nov 12, 2023 at 12:10:50AM +0000, Eric Wong wrote:
> > > Henrik Grimler <henrik@grimler.se> 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.
Aha, I see, thanks for the explanation! Without the single quotes, and
after escaping parantheses, lei works as expected.
For the record, I read some old posts where query was '' quoted, and
thought it was the way to do it (for example
https://people.kernel.org/monsieuricon/lore-lei-part-1-getting-started
and https://josefbacik.github.io/kernel/2021/10/18/lei-and-b4.html)
Best regards,
Henrik Grimler
next prev parent reply other threads:[~2023-11-12 11:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 22:44 [Bug] lei: extra quotes inserted into query with AND/OR Henrik Grimler
2023-11-12 0:10 ` Eric Wong
2023-11-12 8:23 ` Henrik Grimler
2023-11-12 9:02 ` Eric Wong
2023-11-12 11:59 ` Henrik Grimler [this message]
2023-11-12 13:24 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231112115916.GA6228@grimlerstat.localdomain \
--to=henrik@grimler.se \
--cc=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).