Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch highlighting issues with carets #895

Closed
MagicalDrizzle opened this issue Oct 26, 2024 · 1 comment
Closed

Batch highlighting issues with carets #895

MagicalDrizzle opened this issue Oct 26, 2024 · 1 comment
Labels

Comments

@MagicalDrizzle
Copy link

Finding literal carets is interpreted by Notepad4 as escaping the latter quote, leading to this highlighting mistake with open quotes (the latter image is the correct highlighting)
1
2

@0hip
Copy link

0hip commented Oct 26, 2024

image

https://ss64.com/nt/for_cmd.html

Escape any Special Characters in command_to_process.

If any of the strings contain characters which need to be escaped such as an Ampersand, Caret or a Pipe, (e.g. a folder path such as
"C:\Demo & Folder") then you have a couple of options:

Escape each special character with ^

FOR /f /"tokens=* delims=" %%G in ('""C:\Demo ^& Folder\demo.exe" "C:\Demo ^& Folder\data.csv""') do echo %%G

or add an escape to the outer set of quotes:

FOR /f "tokens=* delims=" %%G in ('^""C:\Demo & Folder\demo.exe" "C:\Demo & Folder\data.csv"^"') do echo %%G

If you are passing the filenames using variables, again you can Escape each special character with ^:

Set _exe="C:\Demo ^& Folder\demo.exe"
Set _datafile="C:\Demo ^& Folder\data.csv"

FOR /f "tokens=* delims=" %%G in ('"%_exe% %_datafile%"') do echo %%G

or add an escape to the outer set of quotes:

Set _exe="C:\Demo & Folder\demo.exe"
Set _datafile="C:\Demo & Folder\data.csv"

FOR /f "tokens=* delims=" %%G in ('^"%_exe% %_datafile%^"') do echo %%G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants