{"id":193,"date":"2021-10-24T10:47:30","date_gmt":"2021-10-24T09:47:30","guid":{"rendered":"https:\/\/adventuresinretroprogramming.wordpress.com\/?p=193"},"modified":"2021-10-24T10:47:30","modified_gmt":"2021-10-24T09:47:30","slug":"10-shells","status":"publish","type":"post","link":"https:\/\/mrgadget.nexus\/t81t-dev\/2021\/10\/24\/10-shells\/","title":{"rendered":"#10: Shells"},"content":{"rendered":"\n<p>Whilst AmigaShell has a lot of nice features, and in many respects it provides a reasonably capable &#8220;language&#8221; for scripting, sometimes it is nice to have something a little more advanced.<\/p>\n\n\n\n<p>From the Aminet site browse to the &#8220;util\/shell&#8221; category and grab &#8220;csh550.lha&#8221; and &#8220;csh550a.lha&#8221; and put the files into our &#8220;XFER&#8221; 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&#8217;t strictly recommended, and I edited my Startup-Sequence to remove the &#8220;LoadWB&#8221; command and instead launched the C-Shell, effectively making my Amiga a &#8220;console&#8221; based OS, albeit one where you had windows and could still run graphical software.<\/p>\n\n\n\n<p>Start an AmigaShell and follow these commands, which you notice is quite different than most of our example command sequences &#8211; you won&#8217;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.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nCd Workbench:\nMakedir CShell\nCd CShell\nLha -M x xfer:csh550\nLha -m x xfer:csh550a\nEcho &amp;gt;&amp;gt;S:User-Startup Path Workbench:CShell ADD\nEcho &amp;gt;&amp;gt;S:User-Startup assign &amp;gt;NIL: csh: Workbench:CShell\n<\/pre><\/div>\n\n\n<p>Be careful to note the case of the lha switches, &#8220;-M&#8221; on the first (avoids an auto-display file) and &#8220;-m&#8221; on the second (stops it asking to overwrite certain files, as the second file is an update). Also double check you double up the &#8216;&gt;&#8217; character on the last two commands. This adds to the Amiga&#8217;s search path on future boots and sets up another &#8220;assign&#8221; for CShell&#8217;s own use, and does it without an editor. Unlike many systems on AmigaShell you put &#8220;redirection&#8221; first. You may have noticed this with the S:User-Startup script in the past having lines starting &#8220;assign &gt;NIL:&#8221;<\/p>\n\n\n\n<p>We won&#8217;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&#8230; Users of Linux or other Unix like systems should get a kick out of this&#8230;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nassign csh: Workbench:CShell\ncsh\nls\n<\/pre><\/div>\n\n\n<p>The &#8220;C-Shell&#8221; here is actually a program that acts like a console shell rather than being an Amiga &#8220;shell handler&#8221; 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 &#8220;built-in&#8221; command of the C-Shell program to list the contents of a directory. The format of the output is much like the &#8220;ls&#8221; program Unix and Linux users will be familiar with. Now try the following.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nman ls\nman dir\n<\/pre><\/div>\n\n\n<p>Hopefully the first command will not pop up a message saying to insert a disk called &#8220;csh&#8221; and will instead, briefly, explain it is equivalent to &#8220;DIR&#8221;. 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 &#8220;hunt the symbol on the keyboard&#8221; (hint, move right three places from &#8220;L&#8221; on your keyboard and use shift, probably) you can use Unix\/Linux style pipes in the C-Shell thus.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nman dir | more\n<\/pre><\/div>\n\n\n<p>The C-Shell &#8220;man&#8221; command actually uses the csh.doc file (which is accesses on the path &#8220;csh:csh.doc&#8221;, 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 &#8220;help&#8221;.<\/p>\n\n\n\n<p>On future boots if you start an AmigaShell and decide you want the C-Shell environment you can type in &#8220;csh&#8221;, or you can remain in the normal shell.<\/p>\n\n\n\n<p>If however you like this other shell edit the file S:Shell-Startup and add a line at the bottom saying just &#8220;csh&#8221;. Your choice of vim, Redit or an AmigaShell &#8220;echo &gt;&gt;&#8221;.<\/p>\n\n\n\n<p>Personally one thing I loved about C-Shell was it has &#8220;tab completion&#8221; so instead of typing in &#8220;cd Work:SomeStupidlyLongNameThatIRegretMaking&#8221; you can, probably, type in &#8220;cd Work:Some&#8221; and hit the tab key.<\/p>\n\n\n\n<p>One thing of note is instead of Amiga&#8217;s &#8220;#?&#8221; wildcard specifier, with C-Shell you have to use an asterisk (*) instead. Actually there is a way of using &#8220;#?&#8221; but it is easier to just use the asterisk.<\/p>\n\n\n\n<p>Another thing that might be worth noting for the future is that internal commands (see &#8220;help&#8221;) can be abbreviated and take precedence over &#8220;external&#8221; commands&#8230; Notably there is a command &#8220;makelink&#8221;, so if you type &#8220;make&#8221; in C-Shell you are calling the internal &#8220;makelink&#8221; command. If you want to use a make program called &#8220;make&#8221; you should type &#8220;Make&#8221;, the upper case &#8216;M&#8217; 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.<\/p>\n\n\n\n<p>A word on exiting the C-Shell. There are basically two ways to exit the C-Shell. The first is by typing &#8220;quit&#8221; which will return you back to the native AmigaShell. The other method is typing &#8220;exit&#8221; which will close the shell window completely, the normal Amiga method of doing this is either &#8220;EndCLI&#8221; or &#8220;EndShell&#8221;. 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 &#8220;quit&#8221; C-Shell with exit and then the EndCLI\/EndShell commands will take effect. If you think about it this &#8220;makes sense&#8221; as until C-Shell exits there is will be a program running in the shell window so AmigaDOS will wait to close the window.<\/p>\n\n\n\n<p>I recall before I had a &#8220;make&#8221; command available I created a simple make like tool with a C-Shell script, using my own special format. It could potentially have &#8220;production&#8221; and &#8220;debug&#8221; 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&#8217;t have the make tool script, but I do still have a sample of my special type of makefile&#8230;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncomp genam -ld\nmain.o main.s ButtonValues.i rxcmds.i presets\ninitfinish.o initfinish.s ButtonValues.i mainscreen.raw\ncheckclick.o checkclick.s ButtonValues.i\nchar.o char.s\nmidi.o midi.s\nrexx.o ress.s rxcmds.i\ntarget pss680ed\n<\/pre><\/div>\n\n\n<p>So &#8220;comp&#8221; (and apparently &#8220;compd&#8221;) told the make tool how to compile things either &#8220;production&#8221; or &#8220;debug&#8221;, then various lines listed the &#8220;object file&#8221;, the &#8220;source file&#8221; and any dependencies, before the &#8220;target&#8221; 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.<\/p>\n\n\n\n<p>The C-Shell manual file probably gave me the hint when I saw the description of it&#8217;s &#8220;if&#8221; command mentioned a time comparison feature, saying &#8220;this feature is especially useful for building makefiles without using any MAKE utility&#8221; and gave and example.<\/p>\n\n\n\n<p>I&#8217;ll spare any detective work you may be tempted to perform&#8230; At the time I was only programming in 68000 assembly and using Devpac 2 from HiSoft as I didn&#8217;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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whilst AmigaShell has a lot of nice features, and in many respects it provides a reasonably capable &#8220;language&#8221; for scripting, sometimes it is nice to have something a little more advanced. From the Aminet site browse to the &#8220;util\/shell&#8221; category<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-amiga"],"_links":{"self":[{"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":0,"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"wp:attachment":[{"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mrgadget.nexus\/t81t-dev\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}