Henrik Grimler <[email protected]> wrote: > Hi Eric, > > On Sun, Nov 12, 2023 at 12:10:50AM +0000, Eric Wong wrote: > > Henrik Grimler <[email protected]> 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.
