From: Dmitry Gutov <dmitry@gutov.dev>
To: john muhl <jm@pub.pink>
Cc: 68864@debbugs.gnu.org
Subject: bug#68864: 30.0.50; project-find-regexp fails on Alpine
Date: Thu, 1 Feb 2024 22:54:53 +0200 [thread overview]
Message-ID: <e9159b31-ed52-450a-a00c-c46d6493e684@gutov.dev> (raw)
In-Reply-To: <87o7d0vvk8.fsf@pub.pink>
On 01/02/2024 19:13, john muhl wrote:
> Dmitry Gutov <dmitry@gutov.dev> writes:
>
>> On 01/02/2024 05:38, john muhl via Bug reports for GNU Emacs, the
>> Swiss army knife of text editors wrote:
>>> The grep on Alpine does not support the --null option.
>>> $ grep --null test *
>>> grep: unrecognized option: null
>>> BusyBox v1.36.1 (2024-01-16 17:10:30 UTC) multi-call binary.
>>> To reproduce:
>>> emacs -Q
>>> M-: (project-find-regexp "test")
>>> Debugger entered--Lisp error: (user-error "Search failed with status
>>> 123: grep: unrecognized option: null")
>>> signal(user-error ("Search failed with status 123: grep: unrecognized option: null"))
>>
>> Hi!
>>
>> That's a problem: apparently it does indeed not support --null or -Z:
>> https://boxmatrix.info/wiki/Property:grep
>>
>> There is another flag we could use, which seems to have a similar
>> enough effect: -z. But from what I can tell, it would make OpenBSD
>> unsupported: https://man.openbsd.org/grep
>
> Even -z is a compile time option:
>
> $ busybox grep -h
> BusyBox v1.36.1 (2024-01-16 17:10:30 UTC) multi-call binary.
>
> Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] …
>
> https://git.busybox.net/busybox/tree/findutils/grep.c#n85
That's... unexpected.
> I couldn’t get busybox to compile with the EXTRA_COMPAT option
> so can’t say if it helps or not.
>
>> Perhaps it would be best to just file a feature request for busybox's
>> support for --null/-Z. Better ideas welcome.
>>
>> In the meantime, you can customize the entry for 'grep' in
>> xref-search-program-alist to use -z.
>
> Would it be possible to have xref check
> grep-use-null-filename-separator and only use --null when
> available? I tried with this crude patch and the results look
> good enough:
>
> --- a/lisp/progmodes/xref.el
> +++ b/lisp/progmodes/xref.el
> @@ -1855,7 +1855,11 @@ xref-search-program-alist
> `((grep
> .
> ;; '-s' because 'git ls-files' can output broken symlinks.
> - ,(concat "xargs -0 " xargs-max-chars "grep <C> --null -snHE -e <R>"))
> + ,(concat "xargs -0 " xargs-max-chars "grep <C>"
> + (when (and (grep-compute-defaults)
> + grep-use-null-filename-separator)
> + " --null")
> + " -snHE -e <R>"))
> (ripgrep
> .
> ;; '!*/' is there to filter out dirs (e.g. submodules).
That would slow down the loading of xref.el, which seems unfortunate,
even if it's only by 0.05s (just measured on my machine; on many others
it will be more).
What we could do, I suppose, is check whether
grep-use-null-filename-separator is set to some explicit value (not
'auto-detect'), and if so, apply it. That would work if xref.el is
loaded late, or if you customized the variable explicitly.
I was also thinking of adding another template parameter like <N>, but
it would be used for 'grep'--would seem odd.
We also could just remove "--null" inside xref-matches-in-files from
grep's command line if the variable is set to this or that. It would be
unfortunate to encounter some false positives, though (though I can't
imagine them now).
prev parent reply other threads:[~2024-02-01 20:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 3:38 bug#68864: 30.0.50; project-find-regexp fails on Alpine john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-01 10:04 ` Dmitry Gutov
2024-02-01 17:13 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-01 20:54 ` Dmitry Gutov [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e9159b31-ed52-450a-a00c-c46d6493e684@gutov.dev \
--to=dmitry@gutov.dev \
--cc=68864@debbugs.gnu.org \
--cc=jm@pub.pink \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.