I now understand that kak_command_fifo and kak_response_fifo are per %sh{}.:echo %sh{junk; echo $?>$kak_reg_a} would require an additional pipe for kak_reg_a that Kakoune would have to read from. I can see the programming to prevent pipe deadlocks getting complicated. Especially if the pipe for kak_reg_a were opened once per session. I suspect Mawww would echo your sentiments, but I’ll keeping looking for ways to make a more perfect union between Kakoune and the shell.
You could as well script what you propose around what already exists (command fifo) but i believe it is too minor of an improvement to pull in some dependency.
Btw about shell union, it bothers me that kakscript uses a quote escaping style different from shell, C, … ("\""=='"'
) so i can’t just printf %q
any string into a kakoune script i generate.
fifo buffers are another way to get return codes out of pipes.
1/ mkfifo work1
to minimize keying create in present working directory, but location doesn’t matter
2/ set up a corresponding kakoune work1 buffer (could be a different name from fifo file)
:e -fifo work1 work1
3/ pipe command output into any buffer and send the return code to work1
(for simplicity this example only creates a return code 5)
work1 is the fifo file name, not the kakoune buffer name
|(exit 5);echo -n $?>work1
4/ the return code is now available from the work1 buffer
5/ run :e -fifo work1 work1 each time before writing to the buffer to prime it to read
otherwise the pipe will wait
This is equivalent or maybe even better than piping to user registers: lifts the restriction on one letter names, full edit function available to retrieve from buffer
Kakoune quoting style is probably off topic for this post, but I would suggest that’s an issue for printf or more realistically you have to write your own script/program to do this.