Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

TEE Problem

Using the following (as an example):

copy srcdir dstdir | tee logfile

the files are copied, and their names both displayed and logged.

BUT, if copy has to prompt (overwrite file y/n?), then the prompt line is not displayed UNTIL the response (y or n) is given, after which both the prompt line and the response are displayed. It would be better if the prompt were displayed BEFORE the user typed the response.
 
This comes from the fact that TEE+pipe flushes on newline. COPY's prompt does not end with a newline: the answer follows the end of the prompt on the same line, the newline comes after a (correct) answer. Having the prompt end with a newline would write one line for each prompt and one for each answer — though this could behave better when STDOUT is redirected.
 
Yes; we wouldn't want COPY to send newline after every prompt normally, but if COPY could detect when its standard output is redirected, it could then issue newline after prompt, in order to make it usable with TEE. OR, even better, when redirected, it could flush the output without issuing a newline.
 
Using the following (as an example):

copy srcdir dstdir | tee logfile

the files are copied, and their names both displayed and logged.

BUT, if copy has to prompt (overwrite file y/n?), then the prompt line is not displayed UNTIL the response (y or n) is given, after which both the prompt line and the response are displayed. It would be better if the prompt were displayed BEFORE the user typed the response.
On my pc I see a different behavior.

Code:
[C:\a]copy srcdir dstdir
C:\a\srcdir =>! C:\a\dstdir (Replace) (Y/N/A/R)? Y
     1 file copied

[C:\a]copy srcdir dstdir | tee logfile
(Replace) (Y/N/A/R)? Y
C:\a\srcdir =>! C:\a\dstdir     1 file copied

[C:\a]copy srcdir dstdir | tee logfile
(Replace) (Y/N/A/R)? N
C:\a\srcdir =>! C:\a\dstdir     0 files copied

So, I see immediately the prompt, but not the filenames, that appear after I have chosen Yes or No.
Do You see a different behavior?

What I consider as strange is that if instead of | I use |! the output is corrupted (usual issue with unicode?).

Code:
[C:\a]copy srcdir dstdir |! tee logfile
(Replace) (Y/N/A/R)? Y
 ■C


Regards

Rodolfo Giovanninetti
 
So, I see immediately the prompt, but not the filenames, that appear after I have chosen Yes or No.
Do You see a different behavior?
Sorry, my original post was not accurate. I immediately see all non-prompted filenames; I also see immediately the "Overwrite (Y/N)?" prompt, but I do not see the filename; if there are several prompts, I see all the prompts, but do not see any of the prompted filenames until either:
1. there is a non-prompted file to be copied, in which case I see all the of previous prompted filenames before the unprompted filename, or until
2. the copy operation is complete, after which I see all the previous (since the last unprompted filename) prompted filenames.
This is because the prompts are sent to stderr, which is not being piped, whereas the filenames are sent to stdout and piped to TEE.

As for "|!", I don't have any documentation, and so don't know what it is intended to do. Isn't "!" the overwrite-noclobber operator? I'm using TCC 13. Which version are you using?
 
The |! is the special PC-DOS style piping operator - diirect the output to a temporary file, on completion make the file STDIN. Nothing to do with nolobber (other than the same character in a nonconflicting syntax).

I suggest you use the feedback on this page to request that the feature be provided in the future.
 
I immediately see all non-prompted filenames; I also see immediately the "Overwrite (Y/N)?" prompt, but I do not see the filename; if there are several prompts, I see all the prompts, but do not see any of the prompted filenames until either:
1. there is a non-prompted file to be copied, in which case I see all the of previous prompted filenames before the unprompted filename, or until
2. the copy operation is complete, after which I see all the previous (since the last unprompted filename) prompted filenames.
This is because the prompts are sent to stderr, which is not being piped, whereas the filenames are sent to stdout and piped to TEE.
I should have added that, when the group of prompted filenames do appear, they all appear together as a single string, with no newline separating them.

Also, if both stdout and stderr are piped (copy src dst |& tee log), then I do not see either the prompted filename nor the prompt, until I first answer the prompt (i.e. output just stops until the [unseen] prompt is answered).
 
The |! is the special PC-DOS style piping operator - diirect the output to a temporary file, on completion make the file STDIN. Nothing to do with nolobber (other than the same character in a nonconflicting syntax).
Thanks, Steve.
I suggest you use the feedback on this page to request that the feature be provided in the future.
Does "this page" refer to the page we are now reading, or was it intended to be a link to another page? I cannot find the term "feedback" anywhere on this page, other than in your post. Or am I misunderstanding you: rather than "feedback" meaning a link somewhere on this page, were you simply saying that I should use the information received in replies in this thread, to request the feature? And, where does one request a feature?
 
Feedback button should be located on the middle left hand side of your browser window.
Screenshot - 1_31_2014 , 15_35_08.png
 
If the "feedback" legend is not present on your browser, get in touch with Rex and 1/ get the URL for the feedback site, and 2/ communicate which browser you use and what its options are to find out why the legend is missing.
 
Back
Top
[FOX] Ultimate Translator
Translate