Conflicting Command Names

nchernoff

Administrator
Staff member
May 16, 2008
42
2
#1
Migrated From JP Software Wiki

The Problem

A 4NT or Take Command internal command has the same name as an external utility that I want to use. For example, when I type TOUCH I get the internal TOUCH command, when what I really want is my old familiar TOUCH.COM. How can I resolve this conflict?

Brute force approaches

You can include the path to the utility, or put the command in double quotes. Any of these will prevent it from matching the name of the internal command:

Code:
d:\bin\util\touch.com
d:\bin\util\touch
"touch"
Another easy solution is to rename the external utility:

Code:
ren d:\bin\util\touch.com oldtouch.com
These are all simple enough if you only need the external TOUCH occasionally. But if you use it often you may want a different approach, something that can be automatically loaded in 4START or TCSTART.

Disable the internal command

You can disable an internal command using SETDOS:
Code:
setdos /i-touch
This is an easy solution. The downside is that you lose access to the internal TOUCH. If you never want the internal TOUCH then that's a benefit, not a problem, of course. But what if you want access to both?

Alias the external command

You can create an alias for the external utility:

Code:
alias t*ouch=d:\bin\util\touch.com
This method will accept T, TO, TOU, TOUC, and TOUCH.

What if you really want to continue typing TOUCH to start your old familiar TOUCH.COM, but still want access to 4NT's internal TOUCH from time to time?

Alias both commands

You can continue using the accustomed name for the external utility, and still have acess to the internal command when you want it.

In general, you can access the internal command, not an overriding alias, by preceeding the name with a * character: Typing *touch will run the internal touch command and ignore the t*ouch alias.

If you don't care for the * as part of the name, or want to more abitrarily change the name of the internal command (e.g. disturb, then define two aliases:

Code:
alias t*ouch=d:\bin\util\touch.com
alias jptouch=*touch
Now when you type TOUCH it will be expanded to the filename of the old favorite utility. JPTOUCH instead runs the internal command.
 
Nov 2, 2008
187
1
#2
When using quotes around the name, eg "shortcut", the named exe file needs in the path for it to work under cmd.exe. This is in the interest of making batches more robust (especially in a setup-condition, one is more likely to wrangle cmd.exe to run cmds on install, and 4nt to process them later).
 
May 30, 2008
122
1
#3
When aliasing the external command, if you don't want to hard code the location of the executable, but prefer to search PATH, use the following:

Code:
alias touch=`%@search[touch]`