The Old Windows Con

I needed a place to record some conversion notes.

I type ‘vi con.txt’.

However, this induces some very argumentative behaviour in vi, and ultimately results in my file not being saved.

A quick check reveals nothing seriously wrong with my filesystem and I had sufficient disk space.

So I investigate further:

lorenz@FRUITBURST ~
$ mkdir tmp && cd tmp/

$ ls -latr
total 0
drwxrwxrwx+ 7 lorenz mkpasswd 0 Mar 14 18:10 ..
drwxr-xr-x+ 2 lorenz mkpasswd 0 Mar 14 18:10 .

$ touch con.txt
touch: closing `con.txt': Bad file descriptor

$ ls -latr con.txt
ls: con.txt: No such file or directory
---------- 0 ???????? ???????? 0 Jan  1  1970 con.txt

$ rm con.txt
rm: cannot remove `con.txt': No such file or directory

$ file con.txt
con.txt: empty

$ rm -rf con.txt

$ mkdir con.txt
mkdir: cannot create directory `con': Not a directory

At this point I start having vague flashbacks to an old ‘magic Windows trick’, that gets mass-mailed to you from time to time from people who really should know better.

A quick google reveals this is a known issue and had stumped a many a users. The file con.txt cannot be created. In fact it isn’t just con.txt, but also any file name matching:

con[\.][a-zA-Z0-9]*

Developers who had written code in Linux and were trying to compile under Windows were in a pickle, they simply could not create con.java, con.c, con.o, or con.exe.

It turns out ‘con’ dates back to the days of Dos 1.0. It is a command, and a reserved word referring to output directed to the console or screen.

The command was typically used to create a file on the fly, rather than opening a batch script and entering commands in there. For example:

copy con myscript.bat

Note, the UNIX equivalent of this would be:

cat >myscript.bat

So put into context, we have a niggly bug that’s nearly 30 years old.

And they say Linux isn’t ready for the Desktop…

This entry was posted in IT and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.