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. 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 _______________________________________________ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel