{ datagubbe }


datagubbe.se » well-known secrets of amigados

Well-known Secrets of AmigaDOS

Documented, undocumented, unfinished and useful

Early 2024

Table of Contents

Got docs?

In keeping with the Commodore tradition of cost cutting, most consumer models of their Amiga line of computers came with severely watered down documentation. The Amiga 500 was an exception from this rule, but owners of later machines - such as the A1200 - may not have gotten any documentation for the command line part of AmigaOS at all.

And, of course, even if this documentation had shipped with the machines, it wouldn't have revealed features that were hidden to anyone without access to official developer documentation or even left completely undocumented or unfinished.

This is a quick look at a few of these interesting features, some more obscure than others, but all of them decidedly useful. Most of them only apply to versions 2.x and/or 3.x of the OS. With that said, let's dive right in!

Wildstar

In AmigaDOS pattern matching, the two characters #? (hash and question mark) are the equivalent of the UNIX and DOS wildcard * (asterisk). The hash means "any number of occurances" and the question mark means "any character": match any number of occurances of any character. This is all good and well and makes perfect sense according to the pattern matching rules of AmigaDOS, but it might also feel a bit cumbersome to type for someone used to the instant gratification of just sprinkling their command lines with asterisks.

Commodore's solution to this was to introduce an in-memory flag that could be toggled to enable using an asterisk as a wildcard in AmigaDOS. At the same time, they introduced similar flags to toggle the floppy drive seek behavior. If empty, all Amiga floppy drives make little clicking noises with regular intervals, when the drive mechanism checks to see if a disk has been inserted. When more users bought hard drives (which meant their floppy drives weren't always occupied), this sound became something of a nuisance and Commodore decided to make it possible to mitigate it somewhat.


Notice how the shell doesn't accept asterisk wildcards until the ARexx script for toggling the wildstar flag has been run. The ARexx script is based on code by Erik Lundevall.

The strange thing is that although these flags were introduced in AmigaDOS 2.0, they remained officially unreachable for end users. It would have made perfect sense for Commodore to introduce a Preferences (system settings) program for them, but it just never materialized. Most users had to rely on third party sources and programs to learn about and utilize these nifty features.

Additional Scripts

Speaking of wildcards, AmigaDOS works completely unlike for example UNIX in this regard. Instead of the shell doing this kind of pattern matching, it's up to every single command to implement this itself (through a well defined API). This means that some commands - mostly third party ones - simply won't accept wildcards, because the author decided to omit them for some reason.

Luckily, AmigaDOS offers a (for its time) perfectly serviceable scripting language. Commodore used this to create three scripts as part of the standard AmigaDOS distribution: PCD, an wrapper for the CD command that remembers the previously visited directory (sort of like cd - in Bash), SPat and DPat. The latter ones act as wildcard-enabled wrappers for arbitrary commands, letting the user do pattern-matching to their heart's content.


See? They exist! Incidentally, the head command is not part of standard AmigaDOS - in fact, I wrote it myself. Since I'm lazy, it doesn't accept wildcards...


...but with SPat, that's not a problem!

CON ED

Just like UNIX and DOS, AmigaDOS offers ways of creating text files without the use of an actual text editor. Output redirection is one example, but all the cool kids copy CON: to the desired file.

MS-DOS aficionados might recognize this, but the the Amiga 1) multi-tasks and 2) has no real text mode. Thus, a brand new console window is opened in which the user can type the text.


Copy CON: like the pros. Note the new window.

The text is then saved by pressing CTRL-\ to abort, upon which the freshly opened console window also automatically closes itself.


Incredible - a text file with the very same contents!

If you don't want a new console window to open, you can use "*" in place of CON:, like so:
copy * textfile
The asterisk represent the current console window. Unless, of course, you've enabled the wildstar flag as described above, in which case you might instead find yourself in a bit of a pickle.

Flush, flush, wack

Although the Amiga has no real text mode, the default behavior is to boot into a CON: window with a command interpreter rather than the Workbench desktop environment. Workbench is started by using the loadwb command, followed by an endcli to close the console. This if of course the standard on all hard drive systems and many a bootable floppy.

What's less known is perhaps that loadwb in fact takes arguments - one of which is the "-debug" flag. This is an interesting flag not just because it follows the UNIX dash standard otherwise not employed in AmigaDOS, but because it adds a whole new pull-down menu to the Workbench.


This "Debug" menu is usually not enabled.

The two menu options added, ROMWack and flushlibs, are intended for developers. However, the flushlibs option might be interesting for normal users as well - it performs the equivalent of the AmigaDOS command avail flush, unloading unused shared function libraries from RAM. This is useful if you're a developer and want to reload them from disk, but it also frees up precious RAM for loading other applications that might not rely on the same libraries.

Alas, most users are probably better adviced to simply run "avail flush" when necessary. Flushlibs is dangerously close to ROMWack, and a misclick on this option will freeze the whole computer and launch a debug console on the serial port. Unless you've got some kind of terminal already connected, all you can do to abort this is to reboot the machine.

Pipe Dreams

Later versions of AmigaDOS sports named pipes - that is, you can redirect output from one program to, for example, the path "PIPE:SomeName" and then read from the same path using another program. It works and it gets the job done, but it lacks the simple elegance of UNIX-style anonymous pipes.

In my experience, this isn't much of a problem. My workflow on the Amiga is different from that on UNIX machines - which is one of the things I like about it. There are third party shells for the Amiga that does feature UNIX style pipes, but I've never bothered installing one. Also, writing lengthy pipelines may be fun, but executing them on a 7 MHz or 14 MHz computer isn't equally satisfying.

Still. Sometimes, just sometimes, I do yearn for that smooth UNIX pipe feeling. And, apparently, so did the developers at Commodore. Thus, in AmigaDOS 2.04, they invented the undocumented shell variables _PCHAR and _MCHAR.

If _PCHAR is set to a specific character (such as "|"), any command line that includes this character will trigger a very specific behavior in the shell: it will look for an executable called pipe in the path and invoke that, passing it the complete triggering command line as an argument. The same goes for _MCHAR.


A very simple "pipe" program in Amiga E demonstrating the _PCHAR behavior by simply echoing back the supplied command line.

This of course means that a program capable of parsing such a command line (including more or less finicky bits like quoting) and handling all the process spawning and input and output redirection via named pipes must be written. Once people learned about this feature (somehow), such third party software naturally appeared - but just as with the wildstar flag, I personally don't understand why Commodore didn't make it more of an official part of their OS distribution in later AmigaDOS releases.

Well-known secrets

These various features are hardly unknown - some are even thoroughly documented - and yet they fascinate me. As a kid I never had a decent AmigaDOS manual and whenever I got wise to one of its many cool features, it made me feel like a proper Amiga pro. Perhaps this text can spread a bit of that sweet, geeky joy. In any case, take care and happy hacking!