Thursday, August 2, 2018

Expanding the FreeDOS COMMAND.COM

The FreeDOS COMMAND.COM (also known as "FreeCOM") is a compatible equivalent to MS-DOS COMMAND.COM. FreeCOM doesn't do anything special; it just creates a command prompt that lets you run programs.

FreeCOM also supports the standard MS-DOS batch programming syntax. Any batch script that runs in MS-DOS should run in FreeCOM. And any batch script you write for FreeCOM will run in MS-DOS COMMAND.COM.

From a recent discussion on the email list, I'd like to suggest an extension to FreeCOM. Maybe this would be better implemented as part of a new alternative shell, but it would be really interesting to see it added as a feature to FreeCOM.

Here's my idea: create a BASIC-like programming language that also supports MS-DOS batch scripts.

DOS batch scripts are simple affairs. Really, the idea behind the MS-DOS batch was to "batch up" a bunch of simple commands. DOS batch programming supports minimal flow control. You can query the exit status (ERRORLEVEL) of the previous command, and you can jump around the script (GOTO) but DOS batch programming doesn't support much else.

I'd love to see an extension to DOS batch programming. Something like a BASIC interpreter would be interesting, if it executed commands in the PATH if the instruction wasn't a keyword.

I wonder if someone is interested in writing a BASIC-like "shell"? Something that uses a combination of BASIC and COMMAND.COM syntax would make the interpreter a "superset" of COMMAND.COM, and an interesting new alternative shell.

Some suggestions for how to extend BASIC and DOS batch programming include:


Variables can store either numerical or string data. Variable names can be of any reasonable length, and can be referenced in uppercase or lowercase.

Use SET to assign values to variables, and BASIC's LET to assign values based on arithmetic. LET becomes a superset of SET:

And surround a variable with % to reference its value:
LET A=%A%​ ​+​ ​1

Possibly allow %% as a prefix to reference the value from a variable, interchangeably: (sloppy, but see later)
LET A=%%A + 1


Use ECHO to display output instead of PRINT:
ECHO Hello world


Support the standard DOS batch programming tests, such as == to test equality, and NOT to negate a test. Add extra constructs to test inequality, greater-than and less-than. One possible solution is to support simple DOS batch programming IF constructs and use Unix-style brackets for the extra constructs:

IF %VALUE%==1 ECHO Equal
IF NOT %VALUE%==1 ECHO Not equal

IF [ %VALUE% EQ 1 ] ECHO Equal
IF [ %VALUE% NE 1 ] ECHO Not equal
IF [ %VALUE% GT 1 ] ECHO Greater
IF [ %VALUE% GE 1 ] ECHO Greater or equal
IF [ %STR% LT "ABC" ] ECHO Less


The FOR statement would need to be extended:
FOR N IN 1 TO 10

Or as a one-line shortcut:

And add a special IN (…) construct to create an iteration over a set:
FOR %%N IN (1 2 3 4 5 6 7 8 9 10) DO ECHO %%N

​(If the language allows %A% and %%A then DOS batch programs would probably work seamlessly. But it's sloppy coding. Other ideas?)


Similar to both BASIC and DOS batch programming, GOTO could use : to mark labels:
LET N=%N% + 1


And of course, comments remain the same from BASIC and DOS batch programming:
REM This is a comment


If you called the BASIC-like "shell" using a special parameter (like /P) then it would be nice for anything e​lse you specify that isn't recognized as a shell statement (assuming other syntax is correct) get treated like an external command. That would make this more like a shell:

Also other internal constructs for CALL and ERRORLEVEL and SHIFT and PATH, but you get the idea.

If you can preserve COMMAND.COM syntax and add a BASIC-like programming language behind it, that would make this an interesting extended shell. Maybe an idea for an interested developer?
Note: Tom points out that Microsoft similarly extended the COMMAND.COM batch programming language when creating CMD.EXE. For example, for /L %%N in (1,1,10) do echo %%N (iterative loops) and SET /A A=%%A + 1 (arithmetic). So this hybrid BASIC-like batch programming language idea is not new.

Sunday, July 22, 2018

Planning FreeDOS 1.3

We've started planning the FreeDOS 1.3 distribution! We previously decided the next release would be an iteration from FreeDOS 1.2. We wanted the next FreeDOS distribution to remain like classic DOS. For example, we won't "retire" any classic commands utilities from Base. But FreeDOS 1.3 is an opportunity to improve and update several things.

Compatibility remains key. FreeDOS 1.3 will remain 16-bit, and will focus on a single-user command line environment, just like classic DOS. The "Base" package group will still contain everything that replicates the functionality found in MS-DOS, although we plan to promote Zip and Unzip from "Util" to "Base." This is because all FreeDOS packages are really zip files, so it makes sense to include tools in "Base" that let you create and modify your own packages. And Zip and Unzip provide a handy way to backup and restore your system; while not compatible with MS-DOS Backup and Restore, Zip and Unzip provide a modern spin on that functionality.

FreeDOS 1.3 will follow a similar release schedule as used in FreeDOS 1.2. The deadlines are: No new packages after September 30, 2018. No new languages after October 31, 2018. Assuming these deadlines, the expected schedule is:

  • November 30, 2018 - FreeDOS 1.3 RC1
  • December 31, 2018 - FreeDOS 1.3 RC2
  • January 31, 2019 - FreeDOS 1.3 release

Please join the freedos-devel email list and contribute to the discussion! Also keep an eye on the FreeDOS Road Map on the FreeDOS Wiki for more updates. Looking for ideas to contribute to FreeDOS? See our Contribute page for several suggestions.

Updating the FreeDOS website

I just wanted to share a quick note that I am planning to update the FreeDOS website. I'm not planning any site redesigns; the website should still look the same. But I am moving to a new web host provider. Among other things, the updated web host will provide and manage https for me.

Dates are approximate, but I'll set up a test site on the new provider in early August, and plan to move the site in mid August. I'll leave the old web host for another week, while DNS changes propagate everywhere. We should be fully on the new web host by late August, and I'll retire the old web host at that time.

The new web host will also include a custom MediaWiki instance for us. Currently, the FreeDOS Wiki runs on a custom MediaWiki hosted at SourceForge. This has worked well, aside from a few unplanned downtimes. Also, the SourceForge-hosted MediaWiki instance doesn't allow outbound emails, which is the main stumbling block to let other users create their own accounts. (Wiki Admins have had to do this, and it's a huge pain; I never remember how to do it.)

I'll plan to move the FreeDOS Wiki in September, well after the website move.

Thursday, July 12, 2018

FreeDOS batch programming quick reference

A few weeks ago, I posted a "quick reference" for our new users. This reference showed the most common FreeDOS commands, including a few important notes for new users.

If you're looking to take the next step in FreeDOS, here's a handy quick reference guide to batch programming.

DOS batch programs are simple scripts that "batches up" several commands into one file. Batch programs have some basic flow control that you can use to do loops and jump to different segments of the program. In batch programs, reference variable values by enclosing the variable name with %, such as %PATH%

What do you want to do?How to do it in a batch program:
Execute another batch script from within a scriptCALL SCRIPT.BAT
Run a command for each file in a listFOR %%F IN (*.TXT) DO EDIT %%F

or at the command line:

The loop variable name can only be one character.
Print a messageECHO Hello world
Jump to a label in a batch file:LOOP
Test the value of a stringIF %VAR%==Y ECHO Yes
Test if a file existsIF EXIST TEMP.DAT DEL TEMP.DAT
Test the return value of the previous commandIF ERRORLEVEL 0 ECHO Success
Test the oppositeIF NOT ERRORLEVEL 0 ECHO Fail
Set the shell's search path for programsPATH C:\FDOS\BIN;C:\MY\BIN

or to reference the existing path:

Use ; to separate paths.
Shift the command line optionsSHIFT or SHIFT 1 or any n

Reference command line options as %1, %2, and so on.
A commentREM This is a comment

Friday, June 29, 2018

FreeDOS commands quick-reference

FreeDOS turns 24 years old today (June 29)! That's a long time for any open source software project. Thanks to our FreeDOS community for keeping things going. And a special "thank you" to our developers, who continue to add new features and fix old bugs. You truly make FreeDOS better!

To celebrate this year's anniversary, I wrote a "quick reference" for our new users. This reference shows the most common FreeDOS commands, including a few important notes for new users.

You may also want to check out the free ebook we published last year: 23 Years of FreeDOS.

What do you want to do?How to do it on FreeDOS:
List directory contentsDIR
-in the directory “above”DIR ..
-in a different directoryDIR C:\FDOS\BIN
Change the current driveD:
Change the current directoryCD \FDOS\BIN
-“up” one directoryCD ..
Display the contents of a fileTYPE FILE.TXT
-one screen at a timeMORE FILE.TXT
Delete a fileDEL FILE.TXT
Copy a directory and its contentsXCOPY DIR NEWDIR
Delete a directory and its contentsDELTREE MYFILES
Create a new directoryMKDIR NEWDIR
Remove an empty directoryRMDIR MYFILES
Rename a file or directoryREN FILE.TXT FILE.OLD
Show all lines in a file that contain “HelloFIND "Hello" FILE.TXT
-without regard for caseFIND /I "Hello" FILE.TXT
Clear the screenCLS
Edit a text fileEDIT FILE.TXT
View and set the dateDATE
View and set the timeTIME
Show the usage for a programDIR /? (for most programs)
Get systemwide helpHELP
Show the command historyHISTORY
Show the DOS versionVER

A few things to remember:
  • DOS commands and filenames can be upper or lowercase (DIR is the same as dir)
  • Pipes (|) are the same on DOS as on Linux
  • Output redirection (>) is the same too
  • . and .. are the same on DOS as on Linux
  • The directory separator is \ (such as C:\ or C:\FDOS or C:\FDOS\BIN)
  • File and directory names can only be 8.3 characters long (such as FILENAME.EXT)
  • DOS uses letters for each drive (C: is the first hard drive)
  • A full path is a drive letter and a directory path

Looking for more? I wrote a full FreeDOS cheat sheet for OpenSource, which you can find here: Celebrating 24 years of FreeDOS: Useful commands cheat sheet.

Saturday, May 19, 2018

Tutorial: Installing extra software with FDIMPLES

The FreeDOS software distribution originally started as a set of programs to replace the functionality of MS-DOS. We surpassed that goal a long time ago, and only our "Base" install distribution replaces the original DOS. If you install the "Full" distribution, you get everything in "Base" plus a bunch of other useful FreeDOS programs that we find useful.

Programs in the FreeDOS distribution are included as "packages" that can be easily installed by the FreeDOS install program. Really, these are just standard zip files with a predictable directory layout, such as BIN for executable programs, HELP for any help files, SOURCE for original source code, and so on.

For the FreeDOS 1.2 distribution, we include the usual "Base" and "Full" packages, which you can install automatically as part of the FreeDOS 1.2 installer. But we also include a bunch of extra programs. These other programs are helpful programs that maybe not everyone will want to install, but we wanted to make available to you as part of the FreeDOS 1.2 distribution.

To install these packages, you use the FDIMPLES program. FDIMPLES is a derivative of the FreeDOS installer, and stands for FreeDOS Install - My Package List Editor Software. Make sure you have the FreeDOS 1.2 installation CD in your CDROM drive, then type FDIMPLES to start the program.

Installing a program

Let's walk through a simple case of installing a program. Maybe this is one of the extra software packages, or maybe you installed just the "Base" software set and want to install other packages later on. I like the game WING, so I'll demonstrate with that.

After you start FDIMPLES, you'll see a list of package sets on the left, and a list of packages from that set on the right. As you navigate through each package, you'll see the full package information below:

To install WING, navigate down to the Games package set, and press Tab to get to the list of packages. Scroll down to the WING package, and press the Space bar to mark it with an X. This selects the package for installation:

You can select other packages, including packages from other package sets. When you're done, select OK at the bottom of the screen. FDIMPLES automatically installs the package or packages for you:

Removing a program

The steps to remove a program using FDIMPLES are basically the same as installing a program with FDIMPLES. To demonstrate, let's remove the WING game we just installed.

Again, when you start FDIMPLES, you'll see a list of package sets and packages:

Navigate down to the Games package set, and press Tab to jump to the list of packages. Scroll down to WING, and press the Space bar to remove the X. This tells FDIMPLES to remove it:

You can select other packages to remove, but for this demonstration, I'll leave it with just the one package. Select OK at the bottom of the screen, and FDIMPLES automatically removes the package for you:

Thursday, May 17, 2018

Tutorial: How to install FreeDOS

Need some help installing FreeDOS 1.2 on your computer? Here is a step-by-step guide to install FreeDOS. This how-to guide is adapted from Installing FreeDOS 1.2 on the FreeDOS wiki. You can find lots more information at our wiki, but I'm posting this guide to the blog so new users can find it with the other FreeDOS tutorials I'm writing here.

Installing FreeDOS uses the same process whether you install FreeDOS in a PC emulator or on actual hardware. Note that if you install in a PC emulator, you will probably need to set your system to boot from CDROM before the hard drive, so the FreeDOS install CDROM will boot first. We recommend the CDROM installer for most users. The “standard” CDROM image should work on most computers and PC emulators. Older computers may need the “legacy” CDROM image instead.

Booting the CDROM installer gives you a menu. You can choose to install FreeDOS, or boot from the system harddisk or from a diskette:

The installer supports different languages, which you can choose. The default is English:

Welcome to the FreeDOS 1.2 install program. We provide a standard warning here. For new users, we recommend installing FreeDOS in a PC emulator or “virtual machine.” If you install FreeDOS on a computer directly, without using a PC emulator, you may overwrite the operating system you have now (for example, Windows.) That's why we include a brief message about that in the FreeDOS distribution:

If your C: drive isn't partitioned for DOS, the installer detects that. To partition your hard drive, the installer will use the FDISK program:

Just follow the prompts. Select 1 to create the DOS partition. This will be your C: drive. Follow the other prompts to create the primary DOS partition. Note that if you don't use all free space to create your FreeDOS partition, you may need to mark the new partition as the Active partition, so FreeDOS can boot from it:

After you partition your hard drive, you need to reboot for FreeDOS to see the changes. Press ESC to exit FDISK. The FDISK program and the installer will warn you that you need to reboot your computer for the changes to take effect. The FreeDOS installer has an option to reboot your computer for you, so just use that:

After rebooting, the installer starts up again automatically. If your C: drive isn't formatted for DOS, the installer automatically detects that and can format it for you:

Your preferred language might not match your keyboard language, so we let you select your keyboard layout separately:

The FreeDOS 1.2 installer has two default install modes: install only those packages that reproduce the functionality of classic DOS (“Base”) or install everything (“Full”). Because FreeDOS is open source software, we give you the option to install source code, too:

Then just sit back and let the installer do its thing. The installer will let you know it has finished installing FreeDOS. Depending on what you chose to install and the speed of your system, the install usually takes a few minutes:

That's it! Reboot your system to begin using FreeDOS:

Want to see a video demo of the FreeDOS installation? We recorded a short video to walk you through installing FreeDOS 1.2 on GNOME Boxes (a free PC emulator for Linux) but the steps are the same for any PC emulator.