SQLite Forum

Sending output to a pipe
What .once and .output do, when they are told to create a piped-into process (rather than a file), is start the specified process in conjunction with creation of a pipe, output of which becomes the new process' stdin and input of which receives the SQLite shell output for some command(s). Meanwhile, the shell does not give its stdin over to the piped-into process or begin processing input in any different way than before.

I can see and semi-agree that it might be possible for the .once code to only start the piped-into process after collecting input for the next metacommand or query, then waiting for that process to finish before trying to collect any more input. That might even do what you expect when you are running the shell interactively. To make .output still work, it would be necessary to collect and queue up all subsequent metacommands and queries up to an ".output stdin" metacommand. I can imagine making that work, too. (I must confess to having imagined much more than ever came to be.)

Once that was working, the behavior would have to be documented carefully because it would be more complex than would usually be expected, and more prone to creation of surprise or confusion.

I'm not sure that the present behavior needs more documentation. I certainly do not see a need for any explanation of how piped-into processes should be expected to interact with the shell when they go beyond simply accepting input on the stream they are given. (The possibilities and combinations are too boundless.) However, I can see that maybe more words might clarify the fact that piped-into processes are created when a meta-command specifies such. The trick would be to add something not evident to those who know what pipes are and what they do.