> On Jun 13, 2023, at 4:02 PM, Jim Hall <jh...@freedos.org> wrote:
> 
> On Mon, Jun 12, 2023 at 4:05 PM Bret Johnson <bretj...@juno.com> wrote:
>> 
>> Rather than merely trying to copy the way MS did/does things regarding
>> IF EXIST X:NUL, I think we can discuss what the "right" way to handle
>> things should be.
> 
> We should still fix the FreeDOS behavior to match the MS-DOS behavior.

Issue #2 is simply a bug.

Issue #1 is a little different. Although Issue #1 matches the behavior of 
MS-DOS, it 
can be assumed to be a bug as well. Even Microsoft changed this to be 
consistent 
in Windows Command Shell at some point. 

> But if we're going to talk about the "right" way to do things, what
> about a new, separate "test" command to evaluate things?
> 
> I'm using Unix and Linux as a model, but not suggesting we emulate
> completely the features of Unix. But the Unix 'test' tool does some
> neat things. My suggestions for a "test" like command:
> 
> TEST /F file
> Returns errorlevel zero if the file exists, nonzero if not. This is like 
> doing:
> IF EXIST d:\path\file [..]
> ..but it puts the test on a separate line in the batch file, and you
> use the errorlevel afterwards to do your condition.
> 
> TEST /D dir
> Returns errorlevel zero if the dir exists, nonzero if not. This is like doing:
> IF EXIST d:\path\NUL [..]
> ..but it can be made more reliable.
> 
> 
> I think string tests are also useful:
> 
> 
> TEST /Z str
> Returns zero if the str is empty, nonzero if not. This is like doing:
> IF z%VAR%==z [..]
> ..but it makes the test more obvious.
> 
> TEST /S str
> Returns zero if the str is not empty, nonzero if empty. This is the
> opposite of "TEST /z str"
> 
> 
> Number value comparisons can also be a handy thing for some batch files:
> 
> 
> TEST /n n1 comp n2
> Test various comparisons on numbers. My nature is to use Fortran-like
> comparisons here, like:
> 
> TEST /n a LT b
> TEST /n a LE b
> Returns errorlevel zero if "a" is less than "b" (for LE, "less than or
> equal") nonzero if not
> 
> TEST /n a GT b
> TEST /n a GE b
> Returns errorlevel zero if "a" is greater than "b" (for GE, "greater
> than or equal") nonzero if not
> 
> TEST /n a EQ b
> Returns errorlevel zero if "a" is equal to "b", nonzero if not
> 
> TEST /n a NE b
> Returns errorlevel zero if "a" is not equal to "b", nonzero if not

I was going to wait until it was completely finished. But, there is no
harm in announcing it now.

I have already written a utility that does this and much more. It is part of 
V8Power Tools for DOS and called VTEST. It weighs in at under 3Kb. 
Because like all the programs in V8PT, it is written in assembly. 

It is capable of things like:

vtest 1234567890123 /gt -56789012345 
vtest /not hello /eq goodbye /and /d c:\ /and /not /f readme.txt
vtest 1 /lt 2 /lt 5 /gt 3 /and /not /c hello my friend /gt Goodbye /or /v 15
vtest  /f 00*.* /lt 005.txt 
vtest /not /f This text document.doc /and /not /f That text document.doc

It 64-bit numbers, long file names and even both case-specific and case-less 
string comparisons. 

All that is working great and it will be available for general testing sometime 
over the next few days. If I can spare a few minutes, possibly tomorrow.

If you are interested, the help text for VTEST can be viewed at:

https://github.com/shidel/fd-nls/blob/master/v8power/help/en/vtest.en 
<https://github.com/shidel/fd-nls/blob/master/v8power/help/en/vtest.en>

Source is at:

https://github.com/LoopZ/V8Power/blob/master/SOURCE/VTEST.ASM 
<https://github.com/LoopZ/V8Power/blob/master/SOURCE/VTEST.ASM>

Binary will be available soon.


Jerome

> 
> 
> _______________________________________________
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel

_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to