🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.misc
Article #2725

Re: Passing path as Batch parameter

#2725
From: Al Dunbar
Date: Fri, 10 May 1991 03:49
40 lines
2166 bytes
In article <RN.1208@mts.ucs.UAlberta.CA>, I wrote:
>In article <1991May5.210006.417@sc2a.unige.ch>, fisher@sc2a.unige.ch writes:
>>In article <375@galileo.rtn.ca.boeing.com>, rfh3273@galileo.rtn.ca.boeing.com
>>(Dick Harrigill) writes:
>>> I have a generic problem with writing batch files.
> 
><<<deletions: wants "if exist directoryname" capability>>>
> 
>> 
>>  SOLUTION:
>>    Use a little known trick to check the existence of a directory and
>>    a bit of fall-through logic.
>> 
> 
><<< deletions: explanation that NUL exists in all directories>>>
><<< code fragment follows: >>>
>> 
>>    set _vd=
>>    if exist %1NUL if exist %1\NUL set _vd=%1
>>    if no%_vd% == no if exist %1\NUL set _vd=%1\
>>    if no%_vd% == no if exist %1.\NUL set _vd=%1
>>    if no%_vd% == no goto no_vd
> 
>A neat trick, but not foolproof. It handles even the
<<<deleted explanation that ".."""""" appears to be valid>>>
 
Here is another way it fails: If you pass the name "BILLY"
where no such directory exists, but a file called BILLY.NUL
does exist, the above code would declare "BILLY" as a valid
directory. The solution to this glitch is to look for
NUL.XXX (which has the same properties of existence as NUL),
because BILLY.NUL.XXX can't exist to throw the code off the
track. Note also, that other device names (CON, PRN) seem
to work in place of NUL, but using NUL makes more sense.
 
 -------------------+-------------------------------------------
 Al Dunbar          | 
 Edmonton, Alberta  |  Disclaimer: "I disclaim disclaimers"
 CANADA             |                              
 -------------------+-------------------------------------------
Technical Details
Message-ID: <RN.1215@mts.ucs.UAlberta.CA>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!mips!atha!aunro!alberta!mts.ucs.UAlberta.CA!Al_Dunbar
References: <375@galileo.rtn.ca.boeing.com> <1991May5.210006.417@sc2a.unige.ch> <RN.1208@mts.ucs.UAlberta.CA>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!mips!atha!aunro!alberta!mts.ucs.UAlberta.CA!Al_Dunbar
From: userAKDU@mts.ucs.UAlberta.CA (Al Dunbar)
Newsgroups: comp.os.msdos.misc
Subject: Re: Passing path as Batch parameter
Message-ID: <RN.1215@mts.ucs.UAlberta.CA>
Date: 10 May 91 03:49:35 GMT
References: <375@galileo.rtn.ca.boeing.com> <1991May5.210006.417@sc2a.unige.ch> <RN.1208@mts.ucs.UAlberta.CA>
Organization: MTS Univ of Alberta
Lines: 40