That's because the line set "var=%%a" is only safe with DisabledDelayedExpansion, else exclamation marks are removed and the carets are used as (secondary) escape characters and they are removed too.īut using the variable var is only safe with EnabledDelayedExpansion, as even a call %%var%% will fail with content like "&"&. Toggling between enable and disabled delayed expansion is neccessary for the safe working with strings, like ! or ^^^xy!z. offįOR /F "usebackq delims=" %%a in (`"findstr /n ^^ t.txt"`) do ( Prefix each line with a line number, using the findstr command, and after reading, remove the prefix. The problem with empty lines can be solved with a trick. The expansion works only reliable, if the delayed expansion is disabled.ĭetection of CR/LF versus single LF seems also a little bit complicated.Īlso NUL characters are problematic, as a FOR-Loop immediatly cancels the reading.ĭirect binary reading seems therefore nearly impossible. The FOR doesn't accept empty lines and lines with more than ~8190 are problematic. The FOR-LOOP generally works, but there are some issues.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
June 2023
Categories |