Saturday, June 22, 2019

My first FreeDOS utilities

On June 29, the FreeDOS Project will officially turn 25 years old! That's a major milestone by any reckoning, and to celebrate we're making June our FreeDOS celebration month.
Following up on the story of how FreeDOS got started, I mentioned that I wrote my own DOS extensions, and I re-used several of these as the first FreeDOS utilities.

When I made that first release, I made the naive assumption that FreeDOS would likely work in three separate teams: a Kernel team, a Shell team, and a Utilities team.

With that first assumption, I collected several of my DOS-alike commands into a single package called "Util." I assumed we would continue to add other programs to "Util" over time. In fact, everyone contributed their own programs independently; it didn't make sense to follow the "teams" model.

But let's go back and look at the original "Util" release. You can find this at ibiblio.

If the code looks amateurish, please remember that I was still a university physics student when I wrote these. I didn't have any real experience as a programmer. I had taught myself programming, and some of these early programs show that.

Util 1.0 included these utilities:

Used ANSI to clear the screen or set color. For example, cls white on blue would clear the screen and set the text colors to grey text on a blue background. Or cls bright yellow on cyan would do the same with bright yellow text on a cyan background.
The standard utility to display the date and allow the user to change it.
Erases one or more files or directories. Using /S would recursively delete subdirectories, but would ask first unless you added the /F option.
Locates a string in one or more text files and prints them. Using /C would simply count the lines that contained the string. The /I option ignored case sensitivity. /N numbered the displayed lines, and /V would "invert" the search to display lines that did not contain the string.
A viewer for Help files. This was intentionally similar to Unix man, and even used a HELPPATH variable to set the locations of the Help files, and PAGER to set the viewer program.
Displays one or more files, pausing at each screenful. A pretty simple program.
Displays a prompt to the screen and waits for the user to press a key before it exits. The /R option returned the key pressed as an ASCII code.
A program to do a "warm" or "cold" reboot of the computer. Based on public domain code from Mike O'Carroll.
Similar to Unix tee, this acts as a filter and saves a copy of its input to a file, while also printing to standard output. Looking at this years later, there are much simpler ways to write this program.
Similar to DATE, the standard utility to display the current time and allow the user to change it.
This is one of those programs that started out as an extended DOS program I'd written for myself, then repurposed it for FreeDOS. The standard TYPE command displays a text file. This version of TYPE can also number the output with the /N option, or squeeze together non-blank lines using /S. You can show special characters, such as control characters with the /C option, ends of lines with the /E option, and tabs using /T. The /A ("All") option was the same as /N/C/E/T. And you can convert case: change everything to uppercase using /U and to lowercase using the /L option.
Converts a text file from Unix format to DOS format. This was especially useful for me because I was working in Linux most of the time, and booting into MS-DOS to run the applications that I needed. Converting text files was very handy.
A simple utility to display a hard-coded version number of the FreeDOS utilities. Since this was very early in FreeDOS history, the project was still called "Free-DOS" (with the hyphen).

There's a code comment that developers should refer to us as "Free-DOS" and not "FreeDOS" because another group got started about the same time as us (a few days after us, I think) and used the name "Freedos." Their project had different goals; I don't remember exactly, but I think they wanted to write everything in Assembly, and I wanted to be more flexible. We standardized on C and Assembly for any FreeDOS "Base" utilities, and generally let developers choose their own programming language for other extended utilities.
There's lots more history to share, and throughout June I hope to write about FreeDOS history and various milestones. Please join me in making June our FreeDOS celebration month!

Saturday, June 15, 2019

How to pronounce FreeDOS

On June 29, the FreeDOS Project will officially turn 25 years old! That's a major milestone by any reckoning, and to celebrate we're making June our FreeDOS celebration month.
When Linus Torvalds released Linux, he didn't originally name it Linux. But the person who hosted the original releases of his new Unix kernel put it in a folder called "linux" and so the name stuck.

But there was a problem. How to pronounce "linux"? I pronounced it "Lie-nucks" until I attended a Linux user meetup and heard others pronounce it "Lih-nucks." There was some online debate about how to correctly say "Linux" until Linus himself settled the debate around 1998 by recording a brief audio clip of himself saying "Hello, this is Linus Torvalds, and I pronounce Linux as Lee-nooks!" And so the debate was settled.

Except that a lot of people had already grown used to saying it the way they wanted. These days, I still hear "Lih-nucks" among most users.

A year later, I was testing a new microphone, and decided to record the test phrase "Hello, this is Jim Hall, and I pronounce FreeDOS as FreeDOS." I never thought people would pronounce FreeDOS any other way, I just thought it was a funny phrase to say to test a microphone.

I posted the audio clip to our site on ibiblio. It's been hiding there for years, I don't know if many people have downloaded it. You can find it on ibiblio. I hope you enjoy it.
There's lots more history to share, and throughout June I hope to write about FreeDOS history and various milestones. Please join me in making June our FreeDOS celebration month!

Saturday, June 8, 2019

FreeDOS and Unix

On June 29, the FreeDOS Project will officially turn 25 years old! That's a major milestone by any reckoning, and to celebrate we're making June our FreeDOS celebration month.
Early FreeDOS was influenced quite a lot by Unix. You can still see traces of it today.

I was a long-time DOS user. When my family replaced our Apple II with an IBM PC, I thought DOS was a huge step up! DOS had more powerful utilities, and once I taught myself about programming, I could create my own utilities to expand the command line.

I used DOS exclusively from sometime in the 1980s until about 1992, when I attended university. I was a physics student, and part of our physics program required FORTRAN programming. To do that, we were given an account on the university's VAX system. But if you asked, you could also get an account on the University's Unix network. Normally, the Unix systems were reserved for computer science students, but I had a lot of friends in the computer science program. They helped me get an account on the Sun Unix systems.

I found VAX to be not that different from DOS. But I found Unix to be really interesting!

On the surface, Unix wasn't too different from DOS. Unix had a command line like DOS. Some of the commands were different (ls instead of DIR, for example) but it was still a command line interface. And Unix was much more powerful than DOS! The power and flexibility of the Unix commands was definitely a step above DOS.

So when I created FreeDOS, I wanted similar power found in Unix.

The first utilities that I contributed to FreeDOS included programs that mimicked Unix. If you look at "Utils 1.0" on ibiblio, you'll find standard DOS utilities like CLS, DATE, DEL, FIND, and MORE. You'll also see programs that were meant to be similar to Unix, like TEE and TRCH.

We also looked for other Unix-like utilities to add to FreeDOS. You may be familiar with the Gnuish utilities. From the Readme: "The GNUish Project was designed to bring GNU programs to small systems running OS/2 and DOS." Some Gnuish programs were ports of GNU utilities, others were written from scratch to provide a similar flavor to the GNU and Unix utilities.

My favorite discovery at the time was a print spooler released by Craig Derouen. After you loaded the SPOOL.DEV driver in CONFIG.SYS, Spool would fill up the LPT print buffer when your PC wasn't so busy. This was a big deal! At the time, you committed to printing from DOS. While DOS was printing (usually through an application) you couldn't do anything else. You had to wait for the entire print job to finish, and with a dot matrix printer (typical) you might wait several minutes to get back to work. With Spool, you could print, then get back to work almost immediately. Your printer might slow down as you ran some command, but your printer would keep printing while you were doing something else. That gave FreeDOS similar functionality to the Unix lpr spooler.

Today, we still have some feature borrowed from Unix. FreeDOS has accumulated several Unix-like utilities over time. In fact, for the next FreeDOS 1.3, we have separated these Unix-like utilities into their own package group. You'll find programs like cal, du, grep, less, nro, tail, which, and others that provide parallel functionality to Unix and Linux.

I don't want FreeDOS to become a "Unix clone," where we try to make FreeDOS into an underpowered Unix system. That would be a disservice to FreeDOS. DOS is quite different from Unix. Where Unix was designed to connect small, dedicated utilities to do more complex jobs, DOS was designed to run applications. The MS-DOS command line was always anemic, enough to let you manage data files and do basic manipulation.

But with FreeDOS, I like to think we've expanded the DOS command line to be more powerful on its own. Heavily influenced by Unix, FreeDOS provides a flexible command line with powerful utilities that let you do almost anything. But like standard DOS, you can still rely on applications for your larger work tasks, such as spreadsheets and word processors. FreeDOS is a great mix.
There's lots more history to share, and throughout June I hope to write about FreeDOS history and various milestones. Please join me in making June our FreeDOS celebration month!

Saturday, June 1, 2019

June is FreeDOS celebration month

On June 29, the FreeDOS Project will officially turn 25 years old! That's a major milestone by any reckoning, and to celebrate we're making June our FreeDOS celebration month.
FreeDOS started out as an extension of my personal programming projects. When my family got our first PC and I tried MS-DOS, I thought it was outstanding. I thought MS-DOS was a great little operating system. It provided a powerful platform where I could run applications and do other work. I think we got our first PC when I was in grade school, and over the next several years I thought of myself as a power user. Over that time, I found several of the standard utilities to be lacking. Eventually, I learned C and started writing little utilities for myself.

I wrote my own extensions. If I needed extra features on the command line, I wrote a replacement DOS command to do it. I think my first enhanced utility program was a new version of TYPE that could do different things, similar to Unix cat. My TYPE could convert to uppercase and lowercase, and could pause after printing a screenful of text so I didn't need to pipe the output through MORE. Later, I kept adding new features to it so it could do even more for me.

Not every new program was a replacement to a MS-DOS command. Some were just new programs that I felt made the command line easier to use. A lot of DOS programmers did the same, and it was common to find public domain utilities (often with source code) on FTP sites that extended and enhanced the DOS command line.

I remember when Windows came out. I didn't get to try Windows 1, but I did use Windows 2 and Windows 3/3.1/3.11 when that became the standard. I wasn't that impressed. Windows was slow and buggy. In comparison, MS-DOS was way more mature and powerful.

It was around this time that I also discovered Linux. I was at university, and I had an account on the Unix systems in our campus computer lab. As an avid MS-DOS user, I thought Unix was great. But it was too expensive for me. When others pointed me to a free version of Unix called "Linux" I had to check it out. I dual-booted my '386 PC with MS-DOS and an early release of SLS Linux. It was great! That Linux didn't have a ton of applications didn't bother me; I used Linux for a lot of my work, and booted into MS-DOS to run spreadsheets and word processors.

In 1994, things changed. Microsoft had started doing interviews with technology magazines that the next version of Windows would do away with MS-DOS. Effectively, Microsoft was killing MS-DOS. I didn't want that; I still ran all my applications and games on MS-DOS. A lot of other folks thought the same.

I decided that if we were going to keep DOS, we would need to write our own. As a novice programmer, I didn't know that writing an operating system would be such work. I thought "start with my DOS utilities, add a command shell, and write a kernel." And on June 29, 1994, I announced a free DOS project that would soon become "FreeDOS":
A few months ago, I posted articles relating to starting a public
domain version of DOS.  The general support for this at the time was
strong, and many people agreed with the statement, "start writing!"
So, I have...

Announcing the first effort to produce a PD-DOS.  I have written up a
"manifest" describing the goals of such a project and an outline of
the work, as well as a "task list" that shows exactly what needs to be
written.  I'll post those here, and let discussion follow.

If you are thinking about developing, or have ideas or suggestions for
PD-DOS, I would appreciate direct email to me.  If you just want to
discuss the merits or morals of writing a PD-DOS, I'll leave that to
the net.  I'll check in from time to time to see how the discussion is
going, and maybe contribute a little to what promises to be a very
polarized debate!  :->

I am excited about PD-DOS, and I am hoping I can get a group started!
There's lots more history to share, and over the next month I hope to write about FreeDOS history and various milestones. Please join me in making June our FreeDOS celebration month!

Saturday, April 6, 2019

Jim is changing jobs

After three years as CIO in local government, over eight years as CIO in public sector, and twenty years of IT Leadership—I’ve decided I want to focus on coaching, advising, and mentoring IT Leaders. I have launched an IT Executive Consulting practice, IT Mentor Group LLC, to help IT Leaders with strategic planning, turnaround situations, and organizational development. I also offer IT Leadership Development training to build new leaders, and Essential IT Management training to help current managers hone their skills.

I am really excited for this new opportunity. It’s not every day that you start your own business!

Starting a company takes a lot of time, and that means less time for other things. So I’ve been slow to respond to my FreeDOS email.

I’ll commit as much time as I can to working on FreeDOS, but please understand that I may be distracted from FreeDOS while I start my business.

Sunday, December 30, 2018

Top ten of 2018

As we wrap up the year, I thought this was a good time to look back at my favorite articles from the FreeDOS blog from 2018. As I reviewed the different blog posts, I realized how much we've written about FreeDOS, and on so many topics. These top ten items span quite a range: tutorials, classic programs, programming practices, and more.

This top-ten list is in no particular order:

1. 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.
(See also: installing extra software using FDIMPLES)
2. How to run FreeDOS on Raspberry Pi
As a DOS-based operating system, FreeDOS carries with it certain assumptions about its operating environment: FreeDOS currently requires an Intel x86 CPU, and a BIOS. So that means you can't run FreeDOS on bare metal on different architectures like the Raspberry Pi. But it is still possible to run FreeDOS on the Raspberry Pi, if you use emulation. This article walks through how to install FreeDOS on the Raspberry Pi under the QEMU PC emulator.
3. Running As-Easy-As on FreeDOS
In the late 1980s and early 1990s, the most common spreadsheet program for MS-DOS was the Lotus 1-2-3 spreadsheet. Lotus 1-2-3 was excellent software, but it was far too expensive for me. I soon discovered the As-Easy-As spreadsheet, a shareware program that provided basically the same functionality and features of Lotus 1-2-3, but at a fraction of the cost. As-Easy-As was my favorite DOS program of the era, no question. And I still have a great fondness for As-Easy-As, many years later. Whenever I install FreeDOS somewhere, I usually install As-Easy-As, as well.
(See also: Quattro Pro on FreeDOS and VisiCalc on FreeDOS)
4. Running WordPerfect on FreeDOS
In the 1980s, my preferred word processor was WordPerfect. It was a great word processing system. WordPerfect was fast, powerful, and streamlined. I liked that WordPerfect "got out of the way" so it only displayed my text, plus a small status bar at the bottom of the screen. I haven't run WordPerfect 5.1 for DOS in a long time. Sure enough, it installs and runs great on FreeDOS! I tested WordPerfect on FreeDOS 1.2, running in a QEMU virtual machine.
(See also: WordStar on FreeDOS)
5. PC emulator screenshots look weird
If you remember the early PC era, or if you are a hobbyist who uses original PC hardware, maybe you wonder why PC emulator screenshots don't quite look like screens running on real hardware. This essay explains why FreeDOS looks different on modern systems versus original PC hardware.
6. Tutorial: Basic navigation on FreeDOS
New users often ask "I installed FreeDOS, but how do I use it?" If you haven't used DOS before, the blinking C:\> FreeDOS prompt can seem a little unfriendly. And maybe scary. So I wanted to write a gentle introduction to FreeDOS, to get you started. This article introduces just the basics: how to get around, and how to look at files.
7. 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. This article served as the announcement of the FreeDOS 1.3 distribution and our planned schedule. However, I'll note that we've fallen behind the original schedule, so we do not expect to meet these dates. Look for updates on the FreeDOS wiki under Releases/1.3.
8. Microsoft open-sources old versions of MS-DOS
Microsoft recently released the source code to MS-DOS v1.25 and v2.0 via a repo on Github. This is a huge step for Microsoft, and I congratulate them for releasing these older versions of MS-DOS under a recognized open source software license!
(See also: Practical thoughts on MS-DOS source code)
9. Yes, Digital Mars C/C++ is Boost Licensed
On August 26 2018, Walter Bright of Digital Mars made an announcement that the Digital Mars C/C++ development system is Boost licensed. This is significant, because the Boost license is recognized by the Open Source Initiative and recognized by the Free Software Foundation. It's great to see more programs being released as open source software!
10. Code review: parsing the command line
This year, we started a new blog article series, "Code Review," where we discuss programming methods in DOS programming. At its core, DOS is a command line operating system. Sure, many users might only use the command line long enough to launch their favorite DOS application or game. But for many FreeDOS users and developers, the command line is where it's at. So this article discusses how to use the getopt function to parse command line options.
(See also: Using catgets/kitten to support languages)

Sunday, November 11, 2018

Code review: simulate typing

This is part of the Code Review series, even though it's not strictly about FreeDOS.

When we released the FreeDOS 1.2 distribution, I recorded a short video about how to install FreeDOS. I prefer to run FreeDOS on my Linux laptop using the QEMU PC emulator, so that's what I used for my "how to" video. But the thing about QEMU is you don't launch QEMU from a GUI control panel, like you might for other PC emulators like VirtualBox. Instead, you create QEMU's virtual disk and define the QEMU virtual machine by typing commands at the command line. So for my video, I needed to type commands as I talked about what I was doing.

As I tried to record my video, I kept running into problems. I’m just not the kind of person who can type commands at a keyboard and talk about it at the same time. I quickly realized I needed a way to simulate typing at the keyboard, so I could create a “canned” demonstration that I could narrate in my video.

After some searching, I didn’t see a command on my Linux distribution that would simulate typing. I wasn’t surprised; that’s not a common thing people need to do. Instead, I wrote my own program to do it. Here's how I did that.


Writing a program to simulate typing isn’t as difficult as it may first seem. I needed my program to act like the echo command, where it displayed output given as command-line parameters. I added command-line options so I could set a delay between the program “typing” each letter, with an additional delay for spaces and newlines. The program basically did this:

For each character in a given string:
  1. Insert a delay
  2. Print the character
First, you need a way to simulate a delay in typing, such as someone typing slowly, or pausing before typing the next word or pressing Enter. The C function to create a delay is usleep(useconds_t usec). Use usleep() with the number of microseconds you want your program to pause. So if you want to wait one second, you would use usleep(1000000).

Microseconds means too many zeroes for me to type, so I wrote a simple wrapper called msleep(int millisec) that does the same thing in milliseconds:
msleep (int millisec)
  useconds_t usec;
  int ret;

  /* wrapper to usleep() but values in milliseconds instead */

  usec = (useconds_t) millisec * 1000;
  ret = usleep (usec);
  return (ret);
Next, you need to push characters to the screen after each delay. Normally, you can use putchar(int char) to send a single character to standard output (such as the screen). But you won’t actually see the output until you send a newline. To get around this, you need to flush the output buffer manually. The C function fflush(FILE *stream) will flush an output stream for you. If you put a delay() before each fflush(), it will appear that someone is pausing slightly between typing each character.


Here’s a simple function I wrote to simulate typing. The echodelay() function takes parameters that describe the delay before printing characters, spaces, and newlines. The last parameter is the string to print. The function loops through the string and pauses before printing each character, then flushes the output buffer. The effect is each character seems to appear one at a time, as though someone were typing at a keyboard:
echodelay (int chdelay, int spdelay, int nldelay, char *string)
  int pos = 0;

  /* add a delay between printing each character in the string,
     depending on the character */

      switch (string[pos])
        case '\0':             /* new line */
          msleep (nldelay);
        case ' ':              /* space */
          msleep (spdelay);
        default:               /* character */
          msleep (chdelay);

      putchar (string[pos]);
      fflush (stdout);
  while (string[pos++] != '\0');
With that, it’s a simple process to write a program to parse the command line, set the different delays, and call the echodelay() function to generate the output with the appropriate delays.
/* echodelay.c */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void echodelay (int chdelay, int spdelay, int nldelay, char *string);
int msleep (int millisec);
int atoipos (char *string);

main (int argc, char **argv)
  int opt;
  int chdelay = 0, spdelay = 0, nldelay = 0;

  /* parse command line */

  while ((opt = getopt (argc, argv, "c:s:n:")) != -1)
      switch (opt)
        case 'c':              /* -c nnn */
          chdelay = atoipos (optarg);
        case 's':              /* -s nnn */
          spdelay = atoipos (optarg);
        case 'n':              /* -n nnn */
          nldelay = atoipos (optarg);
        default:               /* unrecognized option */
          fprintf (stderr, "Usage: echodelay [-c millisec] [-s millisec] [-n millisec] [text..]\n");
          exit (1);

  /* pass all remaining options as text to echodelay() */

  for (opt = optind; opt < argc; opt++)
      echodelay (chdelay, spdelay, nldelay, argv[opt]);
      putchar (' ');

  putchar ('\n');

  exit (0);

echodelay (int chdelay, int spdelay, int nldelay, char *string)


msleep (int millisec)


atoipos (char *string)
  int val;

  /* wrapper to atoi() but always a positive return value */

  val = atoi (string);

  if (val < 0)
      val = 0;

  return (val);
And compile it like this:
gcc -Wall -o echodelay echodelay.c
In a shell script, I had commands to print a “prompt,” then simulate typing a command before executing the command. For example, this example to list the contents in your /tmp directory:
echo -n 'prompt$ '
echodelay -c 500 -s 1000 -n 2000 'ls -lh /tmp'
ls -lh /tmp
This is a fairly straightforward C program to simulate typing. I wrote it quickly to do a single job, but it does the job to simulate typing while I narrated my how-to video. In this way, I didn’t need to think about what I was typing while I was trying to describe it. If you need to simulate typing for a similar task, I hope you find this program useful.