![Examining the Hamilton C Shell](https://data.docslib.org/img/3a60ab92a6e30910dab9bd827208bcff-1.webp)
EXAMINING ROO M Examining the Hamilton C Shell Unix power for OS/2 Scott Richman tarting OS/2 for the first time was, file system), long filenames, and threads. in the background and the server will for me, like unlocking a Ferarri, Additionally, the Shell supports large be kept busy. sitting behind its wheel and find­ command lines and pipes (up to 64K) ing a Yugo's dash. What a disap­ and includes faster and more powerful Supporting Procedures pointment. Sure, the engine and utilities than those supplied with OS/2. Script programmers can create C Shell suspensionS were first rate, but the con­ This is more than Unix - this is a pow­ procedures, which are more like func­ trols were minimal, the clutch was stiff, erful requirement for development un­ tions: They accept a parameter list and and the pedals were nonresponsive! der OS/2. The ability to execute C shells return a value. These procedures are OS/2 comes with great stuff, but CMD simultaneously in different Presenta­ compiled into C Shell memory and are .EXE, the default command-line pro­ tion Manager (PM) text windows con­ then executed as new shell commands. cessor, is poor compared to the pow­ verts your PC into a flexible workstation. Procedures can greatly extend the erfuloperating system beneath. CMD.EXE The Hamilton C Shell comes with power and flexibility of your environ­ appears to be a port of the MS-DOS many programs and shell scripts. To ment. COMMAND.COM and lacks the major install the Shell, you simply copy the As an example, consider ZCW.CSH features of a serious front end. files to their new home, and modify (Listing Two, page 106), which is used Fortunately, there's a tool that fills your CONFIG.SYS. The Shell program, to build a C++ PM program. ZCW.CSH this gap. The Hamilton C Shell is a CSH.EXE, can be executed in a text defines a procedure that receives a file­ collection of programs that takes ad­ window of the PM or as a non-PM name as its parameter. The script calls vantage of OS/2 features to create a character-mode application. the procedure at the end: The Shell faster, more powerful environment for reads the file once, compiles the proce­ serious OS/2. users. The Hamilton C Scripts dure and executes the compiled code Shell efficiently uses OS/2 to imple­ Scripts allow you to program the many from that point on. In other words, the ment a superset of the C shell environ­ commands and features with full sup­ zcw procedure is now treated like an­ ment used in the Berkeley flavor of port for complex logic, looping, nested other C Shell command. Unix. The Shell supports a powerful control statements, and symbols. Scripts Listing Three (page 106) shows the script language borrowing C's con­ are composed of C Shell commands, global edit procedure ged, which can structs. OS/2 programs, and comments pre­ be used to globally edit several files. fixed by the pound character (#). For instance, you can edit all .H files C Shell for OS/2 This combination can produce po­ and change your last name from "Love­ The Hamilton C Shell is not a quick tent applications. Scripts can be com­ joy" to "Stern," using the command port of a Unix shell from another sys­ posed and tested interactively at the ged slLovejoylSterni *.h. As with zcw, tem. The Shell was created from scratch, command level or typed into files and the Shell reads and compiles the proce­ implemented with modem compiler tech­ run later. The Shell assumes that files dure and executes ged as it would any nology, and designed to fully take ad­ with extensions of .CSH are C Shell other C Shell command. vantage of the powerful OS/2 architec­ script files. Scripts can read user input ture, including HPFS (high-performance and can be used recursively. Variables For example, Listing One (page 106) Users can create local, environmental, Scott is an independent software con­ presents CTL_T.CSH, a script to send a and C shell global variables. These sym­ sultant specializing in systems and ap­ Ctrl-T to COM1: every 400 seconds. It's bols can contain any text representing plications programming under ViliS, useful when logged onto a busy termi­ pathnames, strings, numbers, and so Unix, DOS, and the Macintosh. He can nal server that impatiently bumps you on, which can be referred to by the be reached at R.R. 3, Box 3471; off when there's no activity. Invoking other Shell components. Long path­ Susquehanna, PA 18847. this sCript, using ctLt &, will execute it names, for instance, could be stored Dr. Dobb'sjournal,january 1991 1 EXAMINING ROO M in variables and used in a command used to format variables. There are also sion. The saved command lines can line to refer to the target location. To provisions to scan strings for substrings, be edited by your favorite text editor define a variable, use the set command concatenate variables, and return string and then submitted to the Shell as a (set a = "this is a ")' To have the Shell lengths. script. The Berkeley history mechanism calculate an expression, use @ instead The Shell is also flexible in treating supplies many nifty ways to access parts of set. symbols as numbers and will allow of previous command lines. When a Additionally, variables can be arrays complicated arithmetic calculations. The command line contains /$, the Shell with full support for C-style subscript­ Shell handles integer and floating-point inserts the last word Cargument) of the ing of the elements. The Shell makes it arithmetic and supports C-like calcula­ previous command line: Repeated se­ easy to access the words which make tions, evaluations and expressions, in­ quences of commands to the same file up a variable. The Shell supplies many cluding switch and case. Variables can (such as edit, compile, link and print) internal variable functions to test and be tested for patterns using the Unix are executed faster and with fewer ty­ manipulate the text within a symbol. pattern-matching expressions. pos because the argument is never re­ The prinif function, for example, is typed. Some of the other history-recall Taking Command commands are shown in Table 1. Command Description The Shell has full command history. It The Shell lets you define aliases, remembers previous command lines, which allow you to abbreviate or re­ which can be recalled through many name any command. Complicated com­ ! • Inserts the first argument different methods. Besides using the mand lines are much easier to work (or word) of the last line. up and down arrow keys to recall past with when they are defined by an alias. ! • Inserts all the arguments lines, you can recall a previous com­ Once an alias is defined, it can be used of the last line. mand line (or specific parts of it) by as another command. command sequence number, or you Because the C Shell furnishes many ! ! Inserts the previous ways to group commands together on line. can recall the last command which con­ tained a specific string. Groups of com­ the same command line, the Enter key mand lines can be saved into a text file has much more power than under con­ Table 1: History recall commands and later read back into another ses- ventional PC systems. Command lines ending with an ampersand (&) will be Utility Description executed in the background. The PS command will show the currently ac­ tive processes and threads created by Cut Outputs specific parts of each line of its input, and allows you to the Shell and their command lines, while specify the character positions and/or the field numbers to include. the Kill command can terminate any job shown by PS, making it easy to Oiff Compares files or directories, and can be instructed to ignore case and spaces. Oiffcan recursively compare the contents of two directo­ manage a multithreaded system. On ries. You can also define the minimum match length to insist on. my wish list of future enhancements, however, is a feature that will display Strings Searches binary files and displays the ASCII strings found within and manipulate the priority of a thread. them. Strings is quite handy for finding the strings embedded within a program or database. File and Command Accessibility xd Dumps the contents of its input to stdout. This wonderful dump utility The Shell controls command-name pars­ can display its input by bytes, words, long words, or floating-point ing through efficient hashing techniques values. xd is fluent in decimal, hex, oct, and even other user-supplied and sophisticated OS/2 features. File­ radixes. xd can be told the offsets at which to begin (and end) its names are expanded within the com­ dump. mand line with greater speed and flexi­ More Flexible full-screen file browser. More will scroll up and down, and bility than under OS/2. For example, search for text and line numbers. It can also format lines with octal when you press the Alt/Ctrl key combi­ and hex values. C programmers will appreciate the feature of display­ nation, the Shell will complete a par­ ing the \n\r escape sequences. tially typed me or command name in the Ls The ultimate DIR program that specifies types of files and displays file current command line. These features information in many different sorted orders. Ls can also display save much time and ensure more accu­ file-size totals. The program will, if told, recursively search the direc­ racy by reducing unnecessary typing.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages4 Page
-
File Size-