rc tools menu: work around ARG_MAX limit #5060
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
when "menu" arguments exceed ~200k bytes, I get "execve failed:
Argument list too long" (even though ARG_MAX is 2MB).
Reproduce with
I hit this with rust-analyzer which can send ~70 code actions to
select from, each with a lengthy JSON object, so the :menu invocation
can sometimes reach the effective limit. It can also become slow
(0.5 seconds), maybe because we fork multiple times per argument.
Fix this by passing arguments through $kak_response_fifo.
The on-accept and on-change callbacks have the same problem (sh -c
string too long), so move them to temporary files. This means we
can get rid of some escaping.
Note that there is currently no dedicated way to stop Kakoune from
passing "$@" to the shell process, so define an extra command that
doesn't take args.
Since we serialize arguments into a single string (using "echo
-quoting"), we need to deserialize them before doing anything else.
We currently don't have an off-the-shelf solution for this. Perhaps
this is an argument for "echo -quoting json" (which has been suggested
before I believe).