I am sure that you have come across mixed documentation and an error.
I believe that the documentation is trying to convey that / f has three mutually exclusive choices: file set, line, command output. One paragraph in the help begins with "You can also use the FOR / F parsing logic for the immediate line." I think "really" means "one." Similarly, the next paragraph says: "... the output of the command ...". Again, I think that "a" means one thing. My discussion of mutually exclusive is how it is implemented more or less.
One of the errors that I am claiming is that one line works like a line if it is at the end of a set of files. Another may be the odd parsing of the quote characters that have been marked.
I think that a high-level parsing algorithm is something like: 1) look for an open bracket, 2) if the first non-empty quote character, use the appropriate handler for the string or command cases. 3) if the first character is not a quote or returnback is used, and the first character is a double quote, then make a file with number 4), if the previous token was a file specification, then continue parsing, but if the previous token was not a file specification, stop parsing
4) explains the behavior of one line at the end of a set of files
The line parsing algorithm is as follows: 1) look for the starting quote as the first quote after the open paren, 2) look for the final quote as the last quote before the closed paren, 3) everything in between is a line (or command) 4) quotes even do not have to be balanced. The following all behaves sequentially with this explanation:
rem space is delimiter for /f "tokens=1,2*" %i in ( "zzz" "yyy" ) do echo i %ij %jk %k rem unbalanced quotes for /f "tokens=1,2* delims=" %i in ( 'echo zzz' yyy' ) do echo i %ij %jk %k rem apostrophe is delimiter for /f "tokens=1,2* usebackq delims='" %i in ( 'zzz' 'yyy' ) do echo i %ij %jk %k
Ξ§pαΊ
source share