
3 ways I use aliases in FreeDOS
Like any DOS, FreeDOS has a limited amount of memory, and everything has a limit that is pretty short compared to what you might think of on Linux. Even though FreeDOS is a more modern version of DOS than MS-DOS, with built-in features like command history and aliases, it’s still limited by the same memory model as the original MS-DOS.
This presents a challenge in using the DOS command line. For example, a single command line, such as a command to set an environment variable like PATH
, cannot be too long or you get an error. Even the workarounds have limitations; for example, you can try this experiment to “stitch” together several 80-character variables into one command, such as to set an environment variable, to see that you can’t get very far by expanding variables to set a longer command:
C:\>set Z=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzz
C:\>set LONG=%Z%;%Z%;%Z%;%Z%
Commandline longer than 125 characters.
C:\>set LONG=%Z%;%Z%;%Z%
C:\>echo %LONG%
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
;zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
z;zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zz
From a practical perspective, you cannot set a very long PATH
. This is a problem if you want to be able to run any program that you’ve installed, at any time. The PATH
stores a list of all the directories that might contain programs you can run, such as C:\freedos\bin
but may contain other program locations like the Open Watcom C compiler at C:\devel\watcomc\binw
or the Open Watcom FORTRAN 77 compiler at C:\devel\watcomf\binw
. Or you might have games installed at C:\games
, with subdirectories for each game like C:\games\senet
or C:\games\freedoom
. You might have other programs you like to use in other locations, like C:\apps\fed
for the FED editor, or D:\apps\aseasy
or D:\apps\word55
for third-party DOS applications like As-Easy-As or Word for DOS. But if you can’t make a command line that’s very long, all of those directory locations can fill up a command line pretty quickly.
The FreeDOS distribution installs tiny COM
program stubs in the C:\freedos\links
directory to run some programs like the IA-16 GCC compiler without adding the full directory location to your PATH
, but I prefer to use command aliases instead.
Using an alias takes up some memory too, but the tradeoff is that my PATH
variable doesn’t get too long. With aliases, you can avoid having to add elements to the PATH
, and instead can just run them like regular commands as though they were in the PATH. Aliases make other things possible too. Here are 3 ways that I use aliases on FreeDOS:
1. To run a command outside the PATH
Before I can compile programs, I need to set up the C compiler so it can run the pre-processor, compiler, and linker programs. For the Open Watcom C compiler, that means adding C:\devel\watcomc\binw
to my PATH
variable, and defining other variables for the compiler. To set everything at once, I use the C:\devel\watcomc\owsetenv.bat
batch file.
When I write programs on FreeDOS, I usually use the fed editor to write the source code. fed is a folding editor that supports all kinds of customizations, which I find makes it easy to use for writing source code. The fed editor is installed in a completely different directory, under C:\apps\fed
. If I want to run fed, I have to add it to the PATH
.
Except there’s no point in adding that to an already-long PATH
just to run one program. Instead, I create an alias to fed, so I can run it just like it was already in the PATH
:
alias fed=C:\apps\fed\fed.exe
If I’m booting into FreeDOS to do some “work” (like doing something in a spreadsheet) I might add an alias to run the spreadsheet from wherever I happen to be. My favorite DOS spreadsheet is As-Easy-As for DOS so I might add this alias:
alias aseasy=D:\apps\aseasy\aseasy.exe
Or if I want to write something in a word processor, such as an article about DOS, I might make an alias to run the application from wherever I am. Microsoft released Word for DOS 5.5 as a free (gratis) download a few years ago, and that’s a very nice word processor for DOS. To run Word without adding it to the PATH
, I create this alias:
alias word=D:\apps\word55\word.exe
2. To run commands with a default parameter
It used to be that when you were done working on DOS, you’d just turn off the computer. But as DOS added disk caches, network access, and other features, shutting down was more than just powering off. These days, the best way to shut down your DOS machine is to first flush the caches and do a few other things; the fdapm command with the poweroff
option will do all of this for you, including a power management (APM) instruction to power off the machine for you. Or if you used the warmboot
option, fdapm will reboot the machine instead.
To make it easier for users to reboot or power off the machine, the FreeDOS distribution creates several aliases to other commands:
alias reboot=fdapm warmboot
alias halt=fdapm poweroff
alias shutdown=fdapm poweroff
This means that if you want to turn off the DOS machine, you just type shutdown and the shell instead executes fdapm to power down the system. If you instead type reboot, the shell instead runs fdapm to reboot.
I use the same method to run a program that is outside the PATH
that otherwise would require a DOS extender program to run. For example, the Open Watcom vi editor is quite nice, and sometimes I might like to use that to edit a few simple files. But if you try to run the vi editor on its own, you’ll get an error that the program cannot be used without the DOS4GW
extender. This is included with Open Watcom, but unless Open Watcom is already in your PATH
, it fails:
D:\SRC> C:\devel\watcomc\binw\vi.exe
Stub exec failed:
\dos4gw.exe
No such file or directory
Instead, I create an alias so that whenever I type vi, I actually run the editor using DOS4GW
:
alias vi=C:\devel\watcomc\binw\dos4gw.exe C:\devel\watcomc\binw\vi.exe
3. To run a command with a different name
Sometimes, my fingers want to type a Linux command when I’m on FreeDOS. For example, to copy a file on DOS, you use the copy command, but you’d use the cp command on Linux. To see the list of files in the current directory, you use the dir command, not the ls command. To display the contents of a text file, you use the type command on DOS, not the cat command from Linux.
To avoid getting the “Bad command or filename” error when all I wanted to do was see a list of files, or display a file, or copy a file, I sometimes add aliases to the equivalent Linux commands:
alias ls=DIR
alias cp=COPY
alias rm=DEL
alias cat=TYPE
I might even update the aliases to add a few command line options to make the output look more like the Linux equivalent, such as displaying file lists in “wide” format, all lowercase, and without the summary:
C:\DEVEL\WATCOMC> alias ls=DIR /W /L /B
C:\DEVEL\WATCOMC> ls
[.] [..] [binl] [binnt] [binp]
[binw] [eddat] [h] [lh] [lib286]
[lib386] [nlm] [rdos] [samples] [src]
[wipfc] instlic.txt license.txt owsetenv.bat readme.txt
readme.w32
Aliases are a great addition to your DOS toolset
Command aliases are a FreeDOS extension in command.com
(called “FreeCOM”), and they work pretty much like command aliases in Bash on Linux. Aliases are a great addition to your DOS toolset, and can make it easier to work from the command line. Explore creating your own aliases in FreeDOS using the alias command!