taripo wrote:where can I read about "path normalization" specifically, "path normalization" in the dos prompt or msdos?
Normalization is a word in math terms that means, a specific representation. In this case normalization is
just the transformation of an arbitrary path to the Fully Qualified Path. I'm sure you can do this intuitively,
if not see the rules at the url, i've given above. The quotes and escape sequences are replaced by the
command line interpreter itself, but the resulting string is handled as one token. So the path normalization
is done on a 'normal' string. The normalization is done on the string and the current directory value, that is
tracked by the system only, it doesn't check any existance of pathes, files, ... :
Code: Select all
Z:\>dir "i bet this path does not exist, but that doesn't matter even if it contains these characters: \/:*?""<>| \..\..\." /B
tokenize.bat
taripo wrote:I guess the quotes make any reference to the nul device, literal in the sense that now it will look only for file objects and not the nul device?
I'm not sure if that is true, it may be, but i won't bet on it; the paragraph Namespace in the given link is a little bit diffuse.
If there is more information available it can surely be found in some MS C++ documentation.
I would handle it in this way, as the namespaces of nul may be linked explicitely to a folder:
foxidrive wrote:Nul doesn't work reliably as a test for directories.
Edit:This means don't use nul, com1, ... within filenames.
taripo wrote:If so, how can the unexpected result in exhibit d be explained?
exhibit dCode: Select all
C:\crp>if exist "c:\crp\nul" echo yeah <--- expected
C:\crp>copy con nul
fd^Z
1 file(s) copied.
C:\crp>if exist "c:\crp\nul" echo yeah <-- unexpected
C:\crp>
The program copy.exe, or a functionality called by copy.exe, may be able to set, unset,
link, unlink, hide, ... namespaces and symbolic links visible to each file system object.
Or it is a result of how windows handles namespaces mentioned in the second point,
directly above, don't know.
taripo wrote:this one below seems strange, I don't know what the tokenization is. I would expect the ^ preceding the space, to have the same
effect as " " and so I would have expected one token [c:\ab cde\a(b)c] and thus I would expect it to see my directory.
exhibit c -improved Code: Select all
C:\ab cde\a(b)c>if exist c:\ab^ cde\a(b)c echo yeah <--- unexpected. i would expect yeah to be echoed.
C:\ab cde\a(b)c>
No your expectation is wrong: I've posted it above. The tokenization is done after ^SPACE is replaced by a SPACE only.
Here is a small batch that should display the tokenization:
Code: Select all
rem tokenize.bat
@echo off
if "%~2" == "" goto :last
:loop
set /P "=[%1] " < nul
shift 1
if not "%~2" == "" goto loop
:last
echo [%1]
Then just use it:
Code: Select all
Z:\>tokenize if exist c:\ab^ cde\a(b)c echo yeah
[if] [exist] [c:\ab] [cde\a(b)c] [echo] [yeah][if] [exist] [c:\ab] [cde\a(b)c] [echo] [yeah]
penpen