- Mar
- 72
- 1
After contemplating the difficulties and impediments associated with trying to combine command grouping with collection of command tails for (likely redirected) output, I am looking into an alternative which relies upon explicitly created pipes. [a] However, I am still stymied by one part of the alternative, which is getting command tails or possibly non-interpreted text into a buffer created by @BALLOC[]. I hope to find a solution to that problem which does not require protecting the text content from further TCC interpretation when the @BWRITE[] function is called. (Such protection partially defeats the purpose of the alternative.)
[a. An "explicitly created pipe" is one created by @FILEOPEN["\\.\pipe\whatever",...] rather than a consequent of redirection. ]
[b. By "non-interpreted text" I mean what is defined within TEXT/ENDTEXT constructs or by "here-document" syntax. ]
It would suffice if there existed internal commands, say BPUTLITERAL and BPUTCOOKED, which could be invoked thusly:
BPUTLITERAL %myBufferHandle {text subject to no interpretation other than end-of-line termination}
or
BPUTCOOKED %myBufferHandle {text subject to all the normal TCC pre-execution expansions}
. As far as I can see, there is no way to synthesize these commands from TCC internal commands and functions. Nor do I see a way to implement them as normal .exe (or other executable forms) because there is no way to pass one of TCC's binary buffer handles to another process where they would have any meaning. Nor is there a way to get a non-TCC-interpreted command tail to such an external program on its command line.
If my above @BALLOC buffer loading scheme must be a bust, a good alternative would be a way to redirect output to a named pipe with an important difference from normal redirection processing. That difference is that execution of the command(s) would not be wrapped by opening and closing the pipe. This would be similar in concept to use of the standard handles, which the shell (TCC or any other) uses without having to open and close them. It could, logically, be worked into the common redirection syntax, 1> or 2>, except that there would be a way to make the handle of a pipe to be written known as 3 (or 4 or ...), so that redirection would take the form 3> (or 4> or ...).
Is there a way to synthesize BPUTLITERAL and BPUTCOOKED in TCC?
Alternatively, is there a way to directly redirect output to an already-open named pipe without TCC closing it afterward?
[a. An "explicitly created pipe" is one created by @FILEOPEN["\\.\pipe\whatever",...] rather than a consequent of redirection. ]
[b. By "non-interpreted text" I mean what is defined within TEXT/ENDTEXT constructs or by "here-document" syntax. ]
It would suffice if there existed internal commands, say BPUTLITERAL and BPUTCOOKED, which could be invoked thusly:
BPUTLITERAL %myBufferHandle {text subject to no interpretation other than end-of-line termination}
or
BPUTCOOKED %myBufferHandle {text subject to all the normal TCC pre-execution expansions}
. As far as I can see, there is no way to synthesize these commands from TCC internal commands and functions. Nor do I see a way to implement them as normal .exe (or other executable forms) because there is no way to pass one of TCC's binary buffer handles to another process where they would have any meaning. Nor is there a way to get a non-TCC-interpreted command tail to such an external program on its command line.
If my above @BALLOC buffer loading scheme must be a bust, a good alternative would be a way to redirect output to a named pipe with an important difference from normal redirection processing. That difference is that execution of the command(s) would not be wrapped by opening and closing the pipe. This would be similar in concept to use of the standard handles, which the shell (TCC or any other) uses without having to open and close them. It could, logically, be worked into the common redirection syntax, 1> or 2>, except that there would be a way to make the handle of a pipe to be written known as 3 (or 4 or ...), so that redirection would take the form 3> (or 4> or ...).
Is there a way to synthesize BPUTLITERAL and BPUTCOOKED in TCC?
Alternatively, is there a way to directly redirect output to an already-open named pipe without TCC closing it afterward?