Addendum for Version 2.0 SKsh A ksh-like Shell for the Amiga Version 2.0 (Copyright) 1988-1992 Steve Koren May 29, 1992 Addendum to Version 2.0 This document describes additions and changes to SKsh since version 1.7. SKsh runs under AmigaDos 2.04 SKsh now operates under AmigaDos 2.04 and only under 2.04. It will not run under AmigaDos 1.3. Version 2.0 of SKsh has the ability to call AmigaDos resident commands, and takes advantages of other 2.04 features such as local envi- ronment variables. All ARP dependencies have been removed and "arp.library" is no longer used by SKsh or the external commands. (Although it is still widely used by other freeware). Old ARP functions have been entirely replaced by dos.library functions in AmigaDos 2.04. Real Pipes SKsh 2.0 now supports real pipes. The "r" option controls this; if "r" is set, SKsh will use true pipes. If unset, it will use temporary files as in version 1.7. True pipes do not require temporary files, and all the processes ex- ecute in parallel. The true pipes use the same "|" nota- tion as the old temporary file pipes. Due to the lack of fork() call in AmigaDos, only external commands can be used with true pipes. If SKsh builtins or control structures are mixed with external calls in a pipeline when true pipes are turned on, only the external commands will run in the background, and others will use temporary files as before. There are a few limitations of real pipes, and I highly recommend you read the UserMan entry on them for more details. options +r The "r" option must be set for real pipes to take effect. It is reset by default, thus providing the old 1.3 behavior. It can be set in the .skshrc file if desired. PIPE_DEV Variable The real pipes in SKsh 2.0 can use any pipe device. The default is the Commodore device, "PIPE:". PIPE_DEV must be set to the name of the device which SKsh will use for pipes. It can be set to any other device following the same conventions as the Commodore device. It may NOT be set to a filesystem or directory name. SKsh Amiga Shell Page 2 Addendum to 2.0 BG_PRI, BG_STACK variables added When executing commands in a pipeline, all but the last are executed in the background. These variables control the priority and stack size of the background processes. If unset, the default to "0" and "4000" respectively. They can be set to any other legal value and pipeline background processes will inherit these values for the stack size and priority. It is often useful to set BG_PRI to "-1" so that CPU intensive pipe commands will not adversely affect the rest of the AmigaDos system. FG_STACK variable added Similar to BG_STACK, FG_STACK controls the stack space for commands executed in the foreground. If unset, it defaults to 4000 bytes. "0" now works in VI mode By popular request, the "0" key now moves the cursor to the beginning of the line in VI mode. The "vi_mode" script has been changed accordingly. srun command handles spaces in arguments and file names In 1.7, srun could not handle imbedded spaces. It now does. File names with imbedded quotes escaped File names which contain imbedded quote characters (such as a file named 'a"b') will now have the quote character backslash escaped during file name completion. File names with multiple imbedded spaces escaped File names with more than one imbedded space were not handled well by 1.7 filename completion. This has been fixed. Previously, completion would not work after the first space. In 2.0, as long as the spaces are backslash escaped, completion will work. Completion will also backslash escape spaces automatically. SKsh Amiga Shell Page 3 Addendum to 2.0 cp buffer size changable, larger by default The "cp" buffer size is now changeable with the -b option. It is also larger by default to provide significantly bet- ter throughput to users of fast hard disks. Cyclic file name completion If a word matches more than one possible file name, SKsh will build a list of the possible matches. Subsequent calls to CC1 (usually TAB or Esc-Esc) will cycle among the various matches. Credit for this idea to Xoper 2.3 by Werner Gunther. Added _ANSI_P4 through _ANSI_P7 Variables for other ANSI escape sequences have been added to allow users of 3 and 4 plane workbenches to set other colors in their prompt strings. Usage is similar to _ANSI_P0 through _ANSI_P3. Resident command replaced with AmigaDos builtin The old ARP compatible resident command has been removed. There is no longer a resident command in SKsh, but the AmigaDos builtin resident command can be used. The syntax of the AmigaDos command is slightly different than the old SKsh command. Command Search Order Changed The search order for commands has been slightly changed to accommodate the AmigaDos resident command list. Aliases and functions are still searched first. Then, commands which have been made resident with the AmigaDos "resident" command are searched, followed by disk based commands, fol- lowed by AmigaDos 2.04 shell builtins such as "run" and "cd". This allows SKsh disk based commands and scripts such as "path" to override the AmigaDos builtins, but yet, for resident commands to take precedence over disk based commands. SKsh Amiga Shell Page 4 Addendum to 2.0 New options to "force" added The SKsh "force" command now has 2 new options. "force -r" will force execution from the AmigaDos resident list - it will never execute a command from disk or an alias or function. This is occasionally useful. "force -e" will force execution as an external (non alias, non function) command, and will use either a resident command or a disk based command. Script execution now faster Use of the new AmigaDos 2.04 disk I/O functions has allowed SKsh script file execution to be over twice as fast as in 1.7, and in some cases, over 4 times faster. Signals cleared after external command is run The signal bits (control C through control F) are now cleared after an external command is run. Previously, ex- ternal commands would often fail to clear the signal bits, and cause SKsh to print an error upon return. Spaces no longer required around pipe symbol In SKsh 1.7 there was a bug which required the use of spaces around the "|" symbol in a pipeline. This has been fixed and pipes of the form "command1|command" will now work even with no spaces. (This is difficult to read and not recommended, but there is no reason to actually prevent it since the Unix shells allow the same syntax). AmigaDos Local variable support SKsh 2.0 supports the new AmigaDos 2.04 local environment variables. AmigaDos 2.04 has two types of environment variables: global (seen by all processes that look), and local (inherited). SKsh previously only supported the glo- bal style. It now supports both. The export, getenv, and unset command have been changed accordingly. SKsh Amiga Shell Page 5 Addendum to 2.0 export command changed WARNING: The "export" command has been changed in a possi- bly non-backwards compatible way. Previously, "export -l" would only set the global SKsh symbol table, and not affect AmigaDos environment variables. This has been changed. Under Sksh 2.0, "export -l" (the letter "ell", not the num- ber "one") will set an AmigaDos local style environment variable. "export -g" will set an AmigaDos global environ- ment variable (the default action). The old meaning of "export -l" has been replaced with "export -L" (not the capital). In addition, the "-b" flag can be used in con- junction with either "-l" or "-g" to mark the variable as "binary". (export -lb or export -gb). I try to keep subsequent versions of SKsh upward compatible from previous releases. However, there is infrequently a need to break upwards compatibility such as in this case, and the best I can do is to point out these cases as clearly as possible. Be careful of this. getenv command changed The "getenv" command now supports two options. "-g" (the default) will copy the value of an AmigaDos global environ- ment variable into an SKsh variable. "-l" will copy the value of a local AmigaDos environment variable into an SKsh variable. unset options added To support AmigaDos global and local environment variables, two options have been added to the unset command. Unset with the "-l" option will remove the definition of an AmigaDos local variable. Unset with the "-g" option will remove the definition of an AmigaDos global environment variable. "-lg" will remove both. These two options can- not be combined with the other options to unset. c:version support SKsh will now report a version number using the AmigaDos version command. SKsh Amiga Shell Page 6 Addendum to 2.0 Execute scripts work Under previous versions of SKsh, a bug in AmigaDos pre- vented automatic execute scripts (via ";!c:execute") from working. The bug has been fixed in AmigaDos 2.04 and these will now work. "ps" command replaced The SKsh builtin "ps" command has been removed and replaced with the ps described below. JM package added to SKsh The JM (Job Manager) package, which includes an enhanced "ps" command, has been added to SKsh. All JM commands now reside under the skshbin: directory. JM must be installed according to the instructions in that package in order to operate correctly. JM provides some significant extensions to the AmigaDos multitasking environment, including auto- matic process priority setting, CPU time reports, an "up- time" command, management of CPU bound tasks by allocating CPU cycles in use defined ratios, and more. See the in- structions for "JM" for more details. JM must be installed separately and will be released independently of SKsh. At each SKsh release, the most current JM will be included. More recent versions of JM may be available. Type alias added For better compatibility with some versions of Unix, "type" is now an alias for "whence". "read" bug fixed A bug which would occasionally crash SKsh if an end of file was signaled from the keyboard during a "read" command has been fixed. "&" can run commands in the background A "&" can be appended to a command to execute it in the background. If so, SKsh will use the BG_PRI and BG_STACK, if set, to determine the stack size and priority of this command. A pipeline can also be executed in the back- ground, but only if it contains only external commands and no builtins or scripts. For example, cat dictionary.txt | fgrep tion | wc -l > ram:out & SKsh Amiga Shell Page 7 Addendum to 2.0 would execute the whole pipeline in the background, produc- ing output in the ram:out file. Three processes would be started: "cat", "fgrep", and "wc" (assuming the "r" option is set). To run a program in the background, use: myprog & "&" only works on pipelines when the "r" option is set. More types added to "view.magic" More file types, including JPEG bitmaps, Vista DEM files, Scenery Animator landscape files, and Imagine IFF files have been added to the supplied view.magic file. "file" (view -t) will now be able to recognize these file types. Most of these do not come with default actions. Supports 2.04 close gadget SKsh now supports the 2.04 CLI close gadget using either any editing mode which defines function keys, or "dumb" non-editing mode. Both the supplied emacs_mode and vi_mode command line editing modes will listen to the close gadget. New keymap editing command A new keymap editing command called EXT (exit) can be bound to any key. This keymap will cause SKsh to quit immediately upon returning to the SKsh prompt. Help messages now work The help messages in the sksh.msg file were previously lost upon being read and would not be displayed using the "help" alias. This has been fixed. split bug fixed A bug which caused the split command to occasionally generate incorrectly split files has been fixed. Possible alternate console device incompatibility SKsh now uses the 2.04 SetMode() call to put the console device into RAW mode. Some alternate console devices do not support this call. If you have problems running SKsh under an alternate console device, this is one possible SKsh Amiga Shell Page 8 Addendum to 2.0 reason. Also, alternate console devices must support the exact and complete set of console codes supported by the AmigaDos device. Few 3rd party console devices have this level of support, and many will not run SKsh. There is nothing I can do about this. If you have compatibility problems, contact the author of the 3rd party device, or use the Commodore device, which works properly with SKsh. ln command added A "ln" command which allows the use of the Unix semantics for linking files has been added. Multiple files can be linked to a directory in one command line. Currently, only hard links are supported. When AmigaDos supports soft links, ln will support the "-s" option. fold command added A "fold" command, similar to the Unix version, has been added. "fold" will read files and fold lines which are longer than a given width into multiple lines. See the de- scription of the "fold" command in ExtCmds.doc for details. paste command added A "paste" command, similar to the Unix command of the same name, has been added. "paste" will read multiple files and join lines from each into multiple columns in the same file. See the description of the "paste" command in ExtCmds.doc for details. fmt command added The "fmt" command is similar to the fmt command in Unix. It is a very simple text formatting utility which can re- wrap words in paragraphs to fit them within a defined margin. It ignores lines with nroff formatting codes, and preserves blank lines. printenv command added The printenv command can print the values of AmigaDos local and global environment variables together with their values. It will either list all variables, or a set of in- dividual variables. See the description of the "printenv" command in ExtCmds.doc for details. SKsh Amiga Shell Page 9 Addendum to 2.0 sane alias added This alias will reset an AmigaDos CLI window to a "sane" state. It is sometimes possible to accidently turn off text output to a window or otherwise disrupt it by display- ing a binary file. This alias will send an escape sequence to reset the CLI window. nice alias "nice" is an alias for "srun -i nil: -o nil: -p -5", and will run a command with a low priority in the background. info command replaced with bdf The "info" builtin command of 1.7 has been eliminated, and replaced with a "bdf" external command. By default, "bdf" produces the same output format as the Unix command of the same name. However, it can also produce the old style out- put format if given the "-o" (old) flag. If need be, "info" can be aliased to "bdf -o". "cat" builtin eliminated In SKsh 1.7, the "cat" command was provided as both a builtin and external command. The builtin version has been eliminated. The external command can be made resident if need be. usecount external command added The "usecount" command can report the number of invocations of SKsh, the number of slave shells running, or the names of each SKsh ARexx port currently open. See the ExtCmds.doc entry for "usecount" for details. Master/slave behavior changed In version 1.7, the master shell could exit while slave shells were still running, causing the slave shells to abort immediately. In 2.0, the master will not exit until all slave shells have also exited. If it tries to quit while there are slave shells running, it will print "Wait- ing for slave shells to exit...", and keep running until it detects that the slave shells have exited. SKsh Amiga Shell Page 10 Addendum to 2.0 ARexx port changed The ARexx port has been changed significantly from SKsh 1.6. (The ARexx port was broken in 1.7). In 2.0, a com- mand line option tells SKsh to start an asynchronous port. This is a separate instantiation of SKsh and can accept ARexx commands at any time. See the UserMan.doc file for details on using the new ARexx port. The "usecount" com- mand can list the names of SKsh ARexx ports, and the "quit_serv" script can be used to stop all or some of the servers. 'U' option flag changed The "insert volume xxx:" requester is now disabled for all SKsh internal commands. It previously was disabled for only a few. The 'U' option flag will enable them. DLW changed In 1.7, the DLW command would not delete a non-alphanumeric character. This has been fixed. SKsh Amiga Shell Page 11 Addendum to 2.0 Misc. Notes If you obtained SKsh from a FISH disk, then READ THIS!! SKsh 2.0 is too large to fit on a singly floppy. Thus, it has been split into two for packing on Fish disks. If you obtained SKsh this way, you MUST combine the two disks into one directory. Each Fish disks contains a "sksh" directory. Sim- ply copy these to the same place on your hard disk. This is NOT optional. FAILURE TO PERFORM THIS STEP WILL CAUSE THE INSTALL SCRIPT TO ABORT SKsh is no longer useful with floppy based systems: the in- stall script will not run that way, and a floppy system does not have enough space to install SKsh. If you want to try to patch something together by hand for floppies, go ahead, but I will not help you when you get stuck. SKsh has some enforcer hits (mostly reads of location 0). I know about these, but since there is currently no version of enforcer which runs on 68040 based systems, it is nearly im- possible for me to find them. As soon as there is a version of enforcer which runs on 68040s, I will fix the enforcer hits. Some people have asked about using SKsh with various utilities that implement console history. Some of these utilities, such as the one that comes with Wshell, do not provide a suffi- ciently complete set of control sequences to fully emulate the AmigaDos console device, and thus will not work. However, the "ConsolEbuffer" program by William J. Fritz (version 1.1) will work fine with SKsh. This program provides a scroll bar for AmigaDos CLI windows. I am no longer distributing a "zoo" file for SKsh. There is now only a "lharc" archive. Also, the archive contains sev- eral subdirectories - it is best to use the "-m" switch to "lharc" to have it create these directories without prompting. The new install script expects all files to be in their proper subdirectories, and it will complain if they are not. There- fore, if you upload SKsh to bulletin board systems, give it to friends, etc, it is imperative that the EXACT .lzh file is transferred. I would like to make a request of people who further distrib- ute SKsh (uploading it to BBS's, etc). I would appricate it if you distribute the ORIGINAL SKsh archive, and not a reas- sembled one. There are a large number of files present, and getting them right is something of a tricky business. It makes life easier for users down the road if they receive the original archive, and the Install_?.?.pp script is less likely to complain about missing or incorrect files. Thanks! That SKsh Amiga Shell Page 12 Addendum to 2.0 said, as always, feel free to give SKsh to anyone who you think might be interested. SKsh Amiga Shell Page 13 Addendum to 2.0 Updating from SKsh 1.7 Please note these differences from SKsh 1.7: 1) The export command has been changed. Some old options no longer perform the same functions. 2) As always, the new .skshinit and sksh.msg file file MUST be used. The .pp form will be faster. The install script will put the new .skshinit into your sksh: directory. Similarly, the new sksh.msg message file must be placed in the sksh: directory. The install script will install this as well. 3) If you see any trouble with command line editing, read this. SKsh 2.0 has slightly optimized command line redraw by not redrawing the prompt when it does not need to. However, for this to work, the PNPC and PNPC2 vari- ables MUST be set correctly. That said, "correctly" is defined as "one more than you think they should be set to". There has been a bug with the PNPC variables for some time in which they are off by one. I could fix this, but I'd rather keep it as it is so that everyone does not have to change their init files if they have re- set it. If you are seeing odd command line editing be- havior (such as, for example, the "UP" or "ZAP" commands not working right), then your PNPC variable is not set right. If you have no non-printing variables in your prompt, such as "$ ", then set PNPC to 1. Else, count up the number of non-printing characters (each $_ANSI_P* variable is worth 10), add one, and use this as your PNPC value. Remember that PNPC2 must also be set correctly. The future of SKsh The future of SKsh is uncertain. There will probably be more minor releases with bug fixes and small sets of new features. There may not be an SKsh 3.0. There are at least 3 projects underway by various people too port the actual Unix ksh to AmigaDos. If even one of these pans out, it will render SKsh substantially less useful than it is now, and there will probably no longer be a reason to continue to develop SKsh in any significant manner. There will almost certainly be an SKsh 2.1 before too long. There have been significant internal changes in SKsh 2.0, and even though I have tried to keep everything compatible, I ex- pect that I have introduced a few problems. 2.1 will attempt to fix these, whatever they are. If you find unusual things in SKsh 2.0, let me know so that I can try to fix them for the next release. SKsh Amiga Shell Page 14 Addendum to 2.0 Thanks to.... Thanks to Maurice LeBrun, Ray Zarling, and Kent Polk for being brave enough to test preliminary versions of SKsh 2.0. These folks found problems that my eyes missed. SKsh Amiga Shell Page 15 Addendum to 2.0