WAD DIR.BTM?

May 20, 2008
11,411
99
Syracuse, NY, USA
What's up with this?

I can successfully execute a BTM named DIR.BTM without parameters.

Code:
v:\> type dir.btm
echo foo

v:\> dir.btm
foo

I cannot execute it with parameters.

Code:
v:\> dir.btm parameter

 Volume in drive V is DATA         Serial number is 6e8a:6d1f
TCC: (Sys) The system cannot find the file specified.
 "V:\.btm"
                   0 bytes in 0 files and 0 dirs
     506,751,782,912 bytes free

 Volume in drive V is DATA         Serial number is 6e8a:6d1f
TCC: (Sys) The system cannot find the file specified.
 "V:\parameter"
                   0 bytes in 0 files and 0 dirs
     506,751,782,912 bytes free
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
WAD (30-year old behavior).

First, don't do that!

Second, this is an ancient kludge because users are unable to use the correct syntax and insert whitespace after the command name (i.e. "dir/w" etc.). In your first example, the parser checks to see if the command is an executable file, and if so it runs that file. In the second example, the command is interpreted as "dir" + ".btm" + "parameter".
 
May 20, 2008
11,411
99
Syracuse, NY, USA
WAD (30-year old behavior).

First, don't do that!

Second, this is an ancient kludge because users are unable to use the correct syntax and insert whitespace after the command name (i.e. "dir/w" etc.). In your first example, the parser checks to see if the command is an executable file, and if so it runs that file. In the second example, the command is interpreted as "dir" + ".btm" + "parameter".

What's the difference? It's still the name of an executable file. Why does adding a parameter make a difference?

I'm well aware of the age-old kludge but I have always thought it applied ONLY to the parameter characters (e.g., DIR/P). "." isn't documented to be a parameter character. Is there a list of characters that will elicit the kludged behavior (";" will, "#" won't ... am I supposed to guess?).
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
Remember how, in COMMAND.COM, to display an empty line you had to do echo. (with a trailing period)? And Microsoft documented this kludge, therefore Rex must duplicate it.

Unless he's gonna write a separate parser for each command, there must be a common arg parser shared by most commands, and it must support such compatibility bodges. I'm guessing his common parser has a flag argument governing miswarts like this; that one of those flags means "punctuation ends the command name, same as whitespace"; and that DIR sets that flag, because setting it draws fewer complaints than not setting it.
 
May 20, 2008
11,411
99
Syracuse, NY, USA
I still don't get it.

"DIR.BTM" is the name of an executable file.

"DIR.BTM foo" is the name of an internal command plus two parameters.

And the behavior is NOT the same as CMD.

Code:
v:\> cmd
Microsoft Windows [Version 10.0.18362.418]
(c) 2019 Microsoft Corporation. All rights reserved.

v:\> type dir.bat
@echo off
echo foo

v:\> dir.bat
foo

v:\> dir.bat parameter
foo
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
Not even for CMD compatibility?

Absolutely not.

This was for compatibility with COMMAND.COM, and retained for compatibility with a zillion existing batch files & aliases (with the minor kludge when MS changed CMD in Windows 2000 to check for an executable name if it's the only argument).

You can submit it to the Suggestions Forum, but I won't implement it. (I'd be willing to bet it would break some of your own batch files.)
 
May 20, 2008
11,411
99
Syracuse, NY, USA
I'd be willing to bet it would break some of your own batch files.
That would depend on exactly what you did. I have never failed to put a space after the name of a command (internal or plugin). All I'm advocating is: if the first space-delimited token is the name of an executable file then leave it alone and look for parameters after it.
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
That would depend on exactly what you did. I have never failed to put a space after the name of a command (internal or plugin). All I'm advocating is: if the first space-delimited token is the name of an executable file then leave it alone and look for parameters after it.

No, no, a thousand times no.

If you absolutely must use dumb filenames, double quote it and it will work as you expect.
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
And before you become too enthralled with the CMD syntax (for the first time ever), you should be aware that CMD treats this completely differently depending on whether the first argument is in the current directory.

Put it in a directory in your PATH, switch to a different directory, and try to execute it in CMD. CMD will treat it like TCC (as DIR + two parameters).
 
May 20, 2008
11,411
99
Syracuse, NY, USA
And before you become too enthralled with the CMD syntax (for the first time ever), you should be aware that CMD treats this completely differently depending on whether the first argument is in the current directory.

Put it in a directory in your PATH, switch to a different directory, and try to execute it in CMD. CMD will treat it like TCC (as DIR + two parameters).
You're right, I'm no fan of CMD compatibility. I only mentioned it because monkeying with a first argument on the command line when it's the name of an executable file just doesn't make any sense to me.

I was writing my own DESCRIBE.BTM (unfortunate choice of name) that uses a stream ":description.txt" and avoids all the Windows SummaryInformation business. Of course I renamed it (for now DESCRIB.BTM). It works pretty well, but now I have a new problem.

I'd like to use a user-defined function, say @DESCRIB[], in PDIR and I'd like it to return the first line of *:description.txt if *:description.txt exists and an empty string otherwise. That's proving difficult.
 
Similar threads
Thread starter Title Forum Replies Date
E Fixed Bug with DIR /Z displaying descriptions Support 8
J Paths shown in DIR /B Support 2
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
Jesse Heines How to? How to display picture creation date with dir command Support 6
DrusTheAxe DIR reports meaningless SYMLINK information Support 14
C show file description? with dir? Support 8
vefatica DIR /F and streams? Support 7
rps Multi-column DIR /v not displaying all files. Support 5
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
rps Dir /Nfv -> Alt-F2 Support 2
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
A TCMD - Dir Command puts out blank lines? Support 16
S Problems with dir command in the debugger Support 5
M TCC incorrect dir output since Windows 1803 Support 6
x13 Problem listing repository files using DIR http(s)://... Support 8
cxxl dir /s works in mysterious ways :( Support 4
vefatica Help nit (FFIND and DIR with /S) Support 0
N Fixed Strange dir behavior Support 6
JohnQSmith Weird DIR output (missing lines) Support 1
C 7zip with date range .vs. filelist created with dir and daterange Support 0
D Towards shared (dir-)history lists Support 3
vefatica WAD DIR /HL still gets names wrong Support 16
vefatica DIR /S /HL? Support 4
H Fixed DIR /G returns wrong sizes Support 2
nickles WAD dir.htm Support 2
vefatica DO dir in /s /a:+d /d"g:\" * ( ... ) Support 26
vefatica DIR \\.\...? Support 4
M Fixed DIR /S /B1 ignores "/S" Support 5
C tcmd.ini not loading from program dir? Support 5
D Fixed Dir /Nm:n has changed Support 1
rps How to? dir /s unexpected results Support 10
vefatica Update to current install dir? Support 8
cgunhouse Problem with "dir /=" Support 4
T dir /h error in empty directory Support 22
P WAD TC 15.0.1.58 x64 crasches with a simple dir command Support 18
CWBillow dir /4 strange Support 2
samintz WAD DIR /B1 and /X Support 2
nickles dir behaves inconsistently Support 5
vefatica DIR, streams, and wildcards? Support 1
vefatica DIR /: /u ... streams not counted? Support 7
vefatica Documentation DIR /B /S /: Support 2
samintz How to? DIR listing for exact match Support 1
dcantor WAD dir "ftp:// ..." fails in TCC 15 Support 7
T How to? dir/pdir - 2nd level down only Support 7
MikeBaas How to? DIR: supress extensions? Support 5
old coot dir /s dies on my C: drive Support 2
A WAD Dir daterange + multiple path wildcards crashes tcc Support 2
old coot TC DIR command has trouble on my SSD Support 2
M Fixed character set in dir/copy Support 3
C odd behavior of "dir" Support 0

Similar threads