Start log thor: Shell V45.0: Oh wow, this was a tough job. The Shell really looked like some kind of BCPL left-over. It took several days just to cleanup the code and turn it into something more readable. BCPL was lurking thru the code all over. No more, folks, no more... The V40 shell was unable to perform the "implicit CD" command properly if the directory name was quoted. It inserted an unnecessary blank space behind the directory name. The shell didn't support multiple backticks on the command line; the backtick parser was simply broken: Fixed handling of asterisk-backtick sequences. The backtick wasn't escaped properly. The shell did not treat TABs as blank spaces. Fixed. Removed the SetClock kludge. Whoever is still using a 1.3 SetClock nowadays cannot be helped anymore and deserves to be crashed. (-; Added a few missing Forbid/Permit locks around access of the list of resident commands. Removed an ugly hack to set the RC and Result2 variables; this really uses now the proper system functions and doesn't attempt to hack directly into the variable buffers. Reworked the parser a lot; it partially tried to fiddle in the internal buffers of file handles using structures that have never been documented. The code now loads full lines at once (no matter how big they are) and then parses within its buffers. This removes all dependencies of implementation details of the file handles. Arguments to redirection did not expand backticks. Fixed. Added a lot of proper error checking if it is low on memory. The internal (and deceased "GlobalVector") is no longer passed thru to all functions. Instead, I'm now using some SAS magic to allocate my data segment myself on each invocaton. Decided not to disable echo-ing for non-interactive shells. Otherwise, we could not debug scripts or the startup-sequence. Sorry, Heinz, but I reconsidered and it's really better this way. Shell V45 re-introduces the handling of the "h" bit. Should it find a command with "pure" and "h" bits set, it makes the command resident automatically. Note that this is (again) the V39 behaivour. Note that "h" is for "hold", not for "hidden". The shell does no longer limit command lines to 512 characters. Command lines can now be unlimited in size, provided the command itself is smaller than the AmigaOs file name size limit (107 characters). The Shell will now auto-expand all of its internal buffers if required to do so. Furthermore, it uses now memory pools for this kind of administration. The shell offers now extended "script" support. In case a script file - i.e. a file whose "s" and "e" bits are set - starts with either the magic characters "#!" or ";!", the string behind this magic cookie is understood as the path to a command parser that shall execute this script. Added support for "file browsing". If the shell encounters now a file as first argument that has its "e" bit cleared (!) and is parsed and recognized as a data- type by the data types system, the shell runs a "viewer" program whose path should be placed in the $VIEWER shell variable. Added support for "stderr" redirection. Therefore, the V45 shell introduces three new redirection symbols: *> filename : redirects stderr to a file *>> filename : appends output to stderr to a file *>< : redirects stderr to the same file that stdout goes into. The shell will also assign the console to the stderr stream should stderr be an interactive stream. Added support for "script stdin". A "<<" will pull the next symbol from the shell script and will push all following lines up to a line starting with this symbol as input into the command. Hence, "<<" is exactly the Un*xoid input redirection. Added a new command line token, the "&" character, the "implicit run". If found, the shell opens named consoles with of a name generated thru utility/GetUniqueID(), and assigns these to the stdin/stdout/stderr of the command, shouldn't redirection be used anyhow. Then the command is detached from the shell segment. Added automatic stack size setup for shell commands. This is a new feature that would hopefully limit the number of stack underflows as it allows application developers to increase the stack automatically without the need for stack swap code. The shell scans now the first 1K of each segment of a loaded binary for the magic cookie "$STACK:". The string behind this cookie is expected to be a decimal number, terminated with a line feed (and an ASCII NUL, i.e. '\0', as for all C strings). This number is then interpreted as the stack size in bytes. The shell will automatically increase the stack size *for this command only*. If the pre-defined stack size is larger than the program-implicit, nothing will happen. AGENDA: Rewrite the parser for shell-variables. This looks currently messy and not very well thought-about. Especially the handling of asterisks is broken here. Rewrite the parser for backticks. This happend already to some degree, but it is not yet perfect. Shell 45.1: The shell did not handle script files correctly that did not end on a line feed. Fixed. The shell bootstrap code was partially broken and could not run the "Initial CLI" correctly. The BCPL startup mechanism was rewritten completely (to the better). Incorporated all traditionally resident commands into the Shell-Seg making this a self-contained shell with a resident segment that is rom-able and can bootstrap the system. Rewrote the shell command line parser to some degree. This implies various changes on how the command line gets interpreted. Good news is that backticks can now also be used to specify the command itself, alias [] works within backticks, and backticks cooperate nicely with aliases in general. Furthermore, the new parser allows multiple, recursive, but non-looping alias expansion, and aliases containing backticks that are expanded correctly. Fixed *>< redirection hits. Fixed generation of result codes, the shell forgot to forward command result codes properly. Fixed stderr redirection: stderr defaults to stdout, it now defaults to the shell output stream; hence, an explicit *>< is required for the old behaivour. Fixed escaping for implicit commands CD,EXECUTE, and others: They no longer escape " and * if found in an unquoted string. Note that this is the proper behaivour, even though this is more a "feature" of ReadItem() than anything else. Fixed the "CD" command: It did not allocate the anchor path from memory resulting in a possibly mis-aligned "FileInfoBlock" and damaged memory. Yikes! Fixed the "resident" command: First of all, it also placed "AnchorPath"s on the stack, which is no good. Second, it did the printf for the resident command list within a loop while Forbid(), making the forbid for the list lock pretty much useless. Reworked set,setenv,alias,unset,unsetenv,unalias: All of these six commands are handled by the same segment, but the division into various subcommands happened in a rather unorthogonal way by second-guessing from the command name. It is now organized in several segments calling the same main routine with parameters. "set" became reorganized a lot as well: "setenv" without parameters is no longer redirected to "list", making this independent of whether external commands are available. "set" reformats now ESC and CSI sequences on the screen consistently by using the BCPL escape character "*". Other non-printables are (as it always has been the case) replaced by the smear-character 0x7f (DEL). Reworked get, getenv for the same reason: One segment, two commands. Reworked "run", but not quite as much as I would like to. This still rolls its own faked input file handle. Even worse, it gets the command line from the undocumented internal buffer of its stdin stream. There's currently no better way of doing it. Added a new option "HEAD" to "path". This will add new paths to the start of the command search path and will hence search them first. Reworked "newshell". It no longer tries to place critical DOS structures on the stack, and will therefore long-word align them correctly all the time. The window open path of NewShell has been changed to CON://130/AmigaShell/CLOSE/SHELL to signal shell usage for console handlers, e.g. ViNCEd. AGENDA: The shell argument parsing is still somewhat wierd. Backticks are not recognized as "quotes" and don't group commands on parsing - this happens only on expanding them. This is mainly the matter of ReadItem() which should be replaced by a custom routine. Further, single quotes are not handled at all. I wonder whether I should touch this or leave it as "compatibility feature". Shell 45.2: Fixed several missing error reports, for example for out-of-memory situations and unability to open redirection files. Changes the style of stderr redirection: Stderr defaults now to stdout, unless redirected otherwise. This is a compatibility cludge for <>NIL: type redirection. Redirection with <> checks now explicitly whether the target file is interactive or NIL: It will fail in all other cases. Redirection into "*" with the run-back operator "&" will now go into the console owner established for the command output rather than the current console. Added PushCD, PopCD and SwapCD commands as build-ins. Re-established the "oldredirect" variable. If set to "on", the shell will check for redirection operators only immediately behind the command name and nowhere else. This is a pre-V36 compatibility feature that was dropped in V40 due to limited ROM space. Added SAVE keyword to UNSETENV to make the changes permanent. Fixed wrong templates for unalias, unset and unsetenv. Reworked ASK a lot; this command allows now numeric and string input, and places the result either on stdout or into a user specified local variable. Shell 45.3: The "&" symbol was broken in several ways: First of all, it unlocked home and current directory twice instead of once, causing possible memory trashes. Further, it did not set CLI->cli_Module correctly which is required for some run-back and stay-resident programs. Thrid, it did not check the very same CLI variable to release the program again, hence might have even unloaded segments that are not meant to be unloaded. Fourth, it did not work well with "Execute" due to the rather clumpsy way the original BCPL shell introduced the execute logic. The "&" handling was more or less rewritten for the 45.3. The new logic introduced another kludge in the shell startup logic (oh no!) but makes it possible to run programs in background *without* destroying stdin, hence unlike run. Therefore "run" is more or less obsolete now. The shell command line parser was turned upside down. Nothing of the old parser is left. The net effect is that the general logic of argument parsing has been improved much. The shell now knows on variable expansion and backtick expansion whether it inserts arguments into quotes, and if so, escapes properly. Fixed handling of aliases in some ways, especially fixed a bug of the 45.2 where the shell forgot to insert a space. Removed handling of ( and ) in pipes. They aren't used by any pipe command I know of and are therefore just here to make the syntax even more cludgy. Fixed handling of interpreter setup by means of #! or #;. The line behind the magic symbols is now parsed thru ReadItem and hence requires proper quoting, so beware! Fixed handling of implicit commands on arguments starting with quotes. The old shell could not run these commands properly due to unadequate re-escaping of the command argument. This is now all handled (hopefully correctly) by one common routine that is also used for variable and backtick sub- stitution. Version 45.4: The 45.3 release caused problems with existing scripts because quoted variables within quotes where escaped by * such that double quotes resulted. While this is correct in principle, it broke already existing scripts. For this reason, a special rule is now applied: Variables within quotes get their first pair of surrounding quotes removed. You can avoid this by setting the variable "keepdoublequotes" to "on": set keepdoublequotes on Pre 45.3 releases generated a wrong error for script files that are read-protected. Fixed. Version 45.5: Fixed the parser state machine such that variables of wierd names like ">t" are possible. The parser used to be quite inconsistent how to handle them. SwapCD has an optional LEVEL argument that defines which level of the directory stack to swap with. The stack extension logic scans now the first 4K for the stack cookie. Setenv SAVE clears now the "e" bit on the saved variables. The asterisk in front of $, [ and ` is now handled correctly again. * escapes the following character, ** escapes the star from escaping, *** is a double star with escaped following control character. Added the possibility to check for the existance of a variable by the $?varname method. $?a will expand to 1 if a is defined, 0 otherwise. $??a will expand to 1 only if a is found as a global variable. Fixed handling of quotes in variables and backticks outside of quotes. Behaivour of the shell depends here now again on the "keepdoublequotes" variable. If "on", the quotes are escaped and the full string is put into quotes, otherwise the string is left alone. If already in quotes, "keepdoublequotes" = "on" escapes quotes within the variable body, otherwise the outermost quote gets removed. Fixed the escaping of the rear backtick of a backtick sequence. StdErr redirection to NIL: by *>NIL: will now clear the console task for the command to be run. Command interpreters specified by the #! or ;! token may now get additional arguments specified on this line. The script file name is inserted between the command and these arguments. Fixed the multiple redirection issue. Fixed handling of alias and redirection. As a side condition, the output of the "set" and "setenv" commands can now be redirected just fine. Version 45.6: Various minor code cleanup concerning the command buffers; they are now all static to the functions they belong to. Fixed recognition of $VIEWER which had to be a local variable to be functional. Removed beta warning message on startup. The shell scans now all hunks of a loaded binary for the stack size. Furthermore, several enhanced safety checks have been added for this feature. Added a german documentation, proof-read and spell-checked the english documentation. Version 45.7: The run-back operator & did not move the shell segment in the seg-array and hence might have crashed some BCPL commands. The stack size search routine got improved quite a lot and is now much faster than before - by a factor of four to five. The "setenv" command clears now the "e" bit of the variables it saves. Added a Shell.guide (Thanks Martin for the help). Version 45.8: Fixed handling of backticks within comments. They are now properly ignored. Fixed handling of equal-signs within arguments. They are now considered similar to blank spaces and consider following double-quotes as function, not as literal.