Whilst AmigaShell has a lot of nice features, and in many respects it provides a reasonably capable “language” for scripting, sometimes it is nice to have something a little more advanced.

From the Aminet site browse to the “util/shell” category and grab “csh550.lha” and “csh550a.lha” and put the files into our “XFER” area. This is C-Shell and once discovering it, I used it almost exclusively when I was on physical Amiga computer. In fact I did something that isn’t strictly recommended, and I edited my Startup-Sequence to remove the “LoadWB” command and instead launched the C-Shell, effectively making my Amiga a “console” based OS, albeit one where you had windows and could still run graphical software.

Start an AmigaShell and follow these commands, which you notice is quite different than most of our example command sequences – you won’t need the first command if you start a new shell, but if you re-use an existing one from a previous blog post then you almost certainly will.

Cd Workbench:
Makedir CShell
Cd CShell
Lha -M x xfer:csh550
Lha -m x xfer:csh550a
Echo >>S:User-Startup Path Workbench:CShell ADD
Echo >>S:User-Startup assign >NIL: csh: Workbench:CShell

Be careful to note the case of the lha switches, “-M” on the first (avoids an auto-display file) and “-m” on the second (stops it asking to overwrite certain files, as the second file is an update). Also double check you double up the ‘>’ character on the last two commands. This adds to the Amiga’s search path on future boots and sets up another “assign” for CShell’s own use, and does it without an editor. Unlike many systems on AmigaShell you put “redirection” first. You may have noticed this with the S:User-Startup script in the past having lines starting “assign >NIL:”

We won’t bother updating the Amiga path for the current session as we are in the CShell directory that we made, continue by typing in the following two commands… Users of Linux or other Unix like systems should get a kick out of this…

assign csh: Workbench:CShell
csh
ls

The “C-Shell” here is actually a program that acts like a console shell rather than being an Amiga “shell handler” so we can just launch it like any program or command. You will notice a subtle change to the prompt text and a not subtle change to the prompt colour. The second command is an “built-in” command of the C-Shell program to list the contents of a directory. The format of the output is much like the “ls” program Unix and Linux users will be familiar with. Now try the following.

man ls
man dir

Hopefully the first command will not pop up a message saying to insert a disk called “csh” and will instead, briefly, explain it is equivalent to “DIR”. The second command produces rather a lot more output. The easy trick is to tap the space bar to pause and the backspace key to continue. But if you want to try “hunt the symbol on the keyboard” (hint, move right three places from “L” on your keyboard and use shift, probably) you can use Unix/Linux style pipes in the C-Shell thus.

man dir | more

The C-Shell “man” command actually uses the csh.doc file (which is accesses on the path “csh:csh.doc”, hence the assign we did earlier) to pull documentation for commands. It is also a general reference for the C-Shell itself. You can get a basic listing of C-Shell commands by typing “help”.

On future boots if you start an AmigaShell and decide you want the C-Shell environment you can type in “csh”, or you can remain in the normal shell.

If however you like this other shell edit the file S:Shell-Startup and add a line at the bottom saying just “csh”. Your choice of vim, Redit or an AmigaShell “echo >>”.

Personally one thing I loved about C-Shell was it has “tab completion” so instead of typing in “cd Work:SomeStupidlyLongNameThatIRegretMaking” you can, probably, type in “cd Work:Some” and hit the tab key.

One thing of note is instead of Amiga’s “#?” wildcard specifier, with C-Shell you have to use an asterisk (*) instead. Actually there is a way of using “#?” but it is easier to just use the asterisk.

Another thing that might be worth noting for the future is that internal commands (see “help”) can be abbreviated and take precedence over “external” commands… Notably there is a command “makelink”, so if you type “make” in C-Shell you are calling the internal “makelink” command. If you want to use a make program called “make” you should type “Make”, the upper case ‘M’ telling C-Shell to ignore the internal commands. This is why more of the shell commands in this blog have typically started with an upper case character.

A word on exiting the C-Shell. There are basically two ways to exit the C-Shell. The first is by typing “quit” which will return you back to the native AmigaShell. The other method is typing “exit” which will close the shell window completely, the normal Amiga method of doing this is either “EndCLI” or “EndShell”. If you are in C-Shell and try to use either EndCLI or EndShell nothing will happen, but if you type the C-Shell command “quit” C-Shell with exit and then the EndCLI/EndShell commands will take effect. If you think about it this “makes sense” as until C-Shell exits there is will be a program running in the shell window so AmigaDOS will wait to close the window.

I recall before I had a “make” command available I created a simple make like tool with a C-Shell script, using my own special format. It could potentially have “production” and “debug” build commands and kept a note of the last compile type so you could just re-build with the same build type as last used. I don’t have the make tool script, but I do still have a sample of my special type of makefile…

comp genam -ld
main.o main.s ButtonValues.i rxcmds.i presets
initfinish.o initfinish.s ButtonValues.i mainscreen.raw
checkclick.o checkclick.s ButtonValues.i
char.o char.s
midi.o midi.s
rexx.o ress.s rxcmds.i
target pss680ed

So “comp” (and apparently “compd”) told the make tool how to compile things either “production” or “debug”, then various lines listed the “object file”, the “source file” and any dependencies, before the “target” line told the make tool what the final program would be, upon which the list of object files would be sent to the de-facto Amiga linker of the period, Blink. If any source file or dependency was newer than the object file on disk the object would be re-built, and if any object file was re-built the target was re-built.

The C-Shell manual file probably gave me the hint when I saw the description of it’s “if” command mentioned a time comparison feature, saying “this feature is especially useful for building makefiles without using any MAKE utility” and gave and example.

I’ll spare any detective work you may be tempted to perform… At the time I was only programming in 68000 assembly and using Devpac 2 from HiSoft as I didn’t have a C compiler. As I recall I got the assembler from a magazine cover disk (Amiga Format) as they were running a tutorial on programming written by a games programmer who was sharing bits and pieces of his code. The program I was building with the above was a voice editor for a Yamaha PSS-680 home keyboard that actually had a 2-operator FM synth engine that you could program. The front panel only had a few parameters but there were more under the hood.

#10: Shells