[comp.sys.ibm.pc] Problem: duplicate .BAT and .COM in DOS 3.3

cy@ashtate.UUCP (Cy Shuster) (06/26/87)

In DOS 3.3, if you have FOO.BAT and FOO.COM in the same subdirectory,
the COM program is always executed, even if you type "FOO.BAT" at the
DOS prompt -- or even "CALL FOO.BAT" (didn't try DETACH :-) ). EXEs
also override .BAT. Happens on a PS/2 Mod 30 as well as AT 339. Surely
this isn't a feature?

--Cy--           ashtate!cy@seismo.CSS.GOV

ralf@b.gp.cs.cmu.edu (Ralf Brown) (06/29/87)

In article <302@ashtate.UUCP> cy@ashtate.UUCP (Cy Shuster) writes:
>In DOS 3.3, if you have FOO.BAT and FOO.COM in the same subdirectory,
>the COM program is always executed, even if you type "FOO.BAT" at the
>DOS prompt -- or even "CALL FOO.BAT" (didn't try DETACH :-) ). EXEs
>also override .BAT. Happens on a PS/2 Mod 30 as well as AT 339. Surely
>this isn't a feature?
>
>--Cy--           ashtate!cy@seismo.CSS.GOV

Yep, it's a feature.  It's been in DOS since 1.0, and maybe even since QDOS :-)
The precedence order is .COM, .EXE, and finally .BAT.  You don't expect that
DOS can read your mind when you type FOO and decide whether you want FOO.COM,
FOO.EXE, or FOO.BAT? :-) (Although I would kind of expect it to use .BAT on a
CALL statement).  Presumably .COM overrides .EXE because .COM is the
final product of a compilation ending with EXE2BIN, and should thus be used
in preference to the intermediate .EXE.

BTW: any extension you give is simply ignored, thus FOO.XXX will work too.
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ARPA:  RALF@B.GP.CS.CMU.EDU               USnail: Ralf Brown
AT&T:  (412) 268-3053 (school)                    Computer Science Department
                                                  Carnegie-Mellon University
DISCLAIMER?  Who ever said I claimed anything?    Pittsburgh, PA 15213
"I do not fear computers.  I fear the lack of them..." -- Isaac Asimov

brown@nicmad.UUCP (Mr. Video) (06/29/87)

In article <302@ashtate.UUCP> cy@ashtate.UUCP (Cy Shuster) writes:
<In DOS 3.3, if you have FOO.BAT and FOO.COM in the same subdirectory,
<the COM program is always executed, even if you type "FOO.BAT" at the
<DOS prompt -- or even "CALL FOO.BAT" (didn't try DETACH :-) ). EXEs
<also override .BAT. Happens on a PS/2 Mod 30 as well as AT 339. Surely
<this isn't a feature?

Yep, it is a feature.  The program searcher, within DOS, searches for the
program name, ignoring the extension.  Search order is EXE, COM and then BAT.

In general, the rule is never have programs with the same name having different
extensions, reside in the same directory.
-- 
	 harvard-\     ihnp4--\
Mr. Video   seismo!uwvax.......!nicmad!brown
	 rutgers-/    decvax--/
		    terminus-/

ward@chinet.UUCP (ward) (06/29/87)

To the best of my knowledge, PC-DOS has never looked at file extensions
typed as command names.  In your message you mentioned being surprised
that DOS 3.3 has COM files override BAT and EXE, so FOO.COM and FOO.BAT
in the same dir causes FOO.COM to run.
  "Right".  DOS has always been that way - just tested it on DOS 2.0,
3.2, and Toshiba T1100+ 2.11 - all ignore any extension, as has always
been my experience.  I often see people typing "edlin.com filename" and
things like that - and never understood why.
  Ideally DOS would work like this: if a bat file exists, run it; if
the bat file refers to the same name, run the COM or EXE.  This would
allow overriding COM and EXE with BAT yet still running the underlying
executable code.  A good example would be FORMAT.BAT which could execute
FORMAT.COM, but for now, you've got to rename format.com formatx.com or
something.
  Did YOU have a version of DOS that "understands" file extensions when
executing commands or batch files?  

rgale@pnet01.CTS.COM (Ryan Gale) (06/30/87)

ward@chinet.UUCP writes
> Ideally DOS would work like this: if a bat file exists, run it; if
> the bat file refers to the same name, run the COM or EXE.  This would
> allow overriding COM and EXE with BAT yet still running the underlying
> executable code.  A good example would be FORMAT.BAT which could execute
> FORMAT.COM, but for now, you've got to rename format.com formatx.com or
> something.

My solution was to put all of my BAT files in their own subdirectory and
put that subdirectory first on the PATH.  COM and EXE files can still be
run (instead of a same-named BAT) by specifying the full path name, but
this is rarely needed (else why would you have the BAT file in the first
place?).
---  
  Ryan Gale
    UUCP: {hplabs!hp-sdd, sdcsvax, nosc}!crash!pnet01!rgale
    ARPA: crash!pnet01!rgale@nosc.mil
    INET: rgale@pnet01.CTS.COM

tr@wind.UUCP (07/01/87)

In article <302@ashtate.UUCP> cy@ashtate.UUCP (Cy Shuster) writes:
$ In DOS 3.3, if you have FOO.BAT and FOO.COM in the same subdirectory,
$ the COM program is always executed, even if you type "FOO.BAT" at the
$ DOS prompt -- or even "CALL FOO.BAT" (didn't try DETACH :-) ). EXEs
$ also override .BAT. Happens on a PS/2 Mod 30 as well as AT 339. Surely
$ this isn't a feature?
$ 
$ --Cy--           ashtate!cy@seismo.CSS.GOV

Call it a feature or a bug, but it has been that way with all the
versions of DOS that I can remember using.

Tom Reingold
INTERNET:       tr@bellcore.bellcore.com
UUCP: 		{seismo,ihnp4,ucbvax,decvax}!bellcore!tr
		{ulysses,allegra,clyde,princeton}!bellcore!tr

cy@ashtate.UUCP (Cy Shuster) (07/06/87)

Thanks for the reminders: if files FOO.COM, FOO.EXE, and FOO.BAT all
exist and the external command "FOO" is typed, the search precedence
has always been .COM, .EXE, and then .BAT (the way I remember the
COM/EXE distinction is that after running EXE2BIN on a .EXE to make a
.COM, you have to delete the .EXE to execute the new .COM). I apologize
for not checking this behavior under prior DOS releases before blaming
3.3.

I suspected 3.3 because I was testing the behavior of the new "CALL"
statement. Anytime syntax calls for "drive:\path1\path2...\filespec"
I tend to include the extension as well. I guess I never realized that
if you keyed in the extension, it was ignored.

--Cy--          cy@ashtate.UUCP