-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcr.cmd
More file actions
30 lines (21 loc) · 806 Bytes
/
Copy pathcr.cmd
File metadata and controls
30 lines (21 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@echo off
setlocal enableDelayedExpansion
::Define CR variable containing a carriage return (0x0D)
for /f %%a in ('copy /Z "%~dpf0" nul') do set "_CR=%%a"
echo Delayed expansion!_CR!OK
GOTO :EOF
:: Define CR to contain a single carriage return character.
:: This also demonstrates that carriage return is stripped before
:: FOR variable expansion
for /f %%a in ('copy /Z "%~dpf0" nul') do (
set "CR=%%a"
echo FOR variable%%aOK
)
:: Normal expansion seems to fail because all carriage returns
:: are stripped from the line after expansion
echo Normal expansion%CR%FAIL
:: Delayed expansion works just fine
echo Delayed expansion!CR!OK
:: Demonstrate that Normal expansion actually works by replacing the
:: carriage return with some other text
echo Normal expansion %CR: