Reputation: 1594
I'm trying to make jrepl.bat work on several lines. See this little test:
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
echo First line%NL%second line | jrepl.bat i o
Is there a reason why it only prints the first line:
Forst lone
?
Upvotes: 1
Views: 463
Reputation: 82337
As @MCND mentioned it's a problem of the child process and that the line is parsed two times.
But it can be done with a simple linefeed.
set LF=^
cmd /q /v /c"echo First line^!LF^!second line" | jrepl.bat i o
This works independent of the delayed expansion mode.
As if delayed expansion is enabled in the batch file, the exclamation marks are escaped in the delayed expansion parser phase (and the carets are removed).
Else with delayed expansion disabled the line with the carets will be executed unchanged in the child cmd.exe process, but there the carets are removed in the special charaters phase so the delayed expansion will also work later.
Upvotes: 2
Reputation: 70943
Pipes are created between processes, so, the echo
command is executed in a separate cmd
instance that does not parse the input line (with the inner line feeds) as you expect.
Try with
setlocal enableextensions disabledelayedexpansion
set NLM=^
set NL=^%NLM%%NLM%^%NLM%%NLM%
cmd /q /v /c"echo First line!NL!second line" | jrepl.bat i o
Upvotes: 0