Interacting with the GNO Shell
Executing Commands A command consists of two parts: a name and its arguments. The command name is the name used to start the command. The name is usually the name of a file which can be executed. The only exceptions are commands which are built-in to the shell. These commands are documented in . Any shell utility command with a filetype of EXE, SYS16, or EXEC, can be executed in this fashion. The command name must be separated from the command arguments with a space. The command arguments are parameters that the command takes as data to work with (In Applesoft BASIC, "HELLO WORLD" would be an argument for the PRINT command). Command arguments are separated from each other with a space. Note that although arguments extend the usefulness of a command, not all commands have arguments. Any arguments entered after the command will be passed by the shell to the program when it starts exectuting. The examples below use the following commands: qtime displays time in English text echo prints arguments to the screen Examples: % qtime It's almost five. % echo II Infinitum II Infinitum At the simplest level the user enters commands to the shell by typing them on the keyboard. gsh includes a command-line editor to help the user enter and edit commands. The editor also provides a way to modify and execute previous commands. Additionally the editor can help complete the names of commands, filenames and variables.
Commandline Editing The following sections provide a complete description of the functions of the command-line editor with short examples depicting how each editing key works. Throughout the examples the underline character, "_", will be used to represent the current cursor position. In addition, "OA" is used to represent the Open Apple key and the term word is used to indicate a string of characters consisting of only letters, digits, and underscores. To the right of a editing key entry is the bindkey function name which is used to remap editing functions to new keys. This information is included for reference purposes only. See for more information on the bindkey command. It should be pointed out that at this stage that the user should not be concerned with what the actual commands used in the examples do, rather the user should concentrate on how the command-line editor functions work.
Command Input These command-line editor keys deal with entering text directly on the command-line. RETURN Newline. The return key is used to terminate line input. gsh then interprets the command on the line and acts accordingly. The position of the cursor on the command-line does not matter. CTRL-D (no bindkey name) Causes gsh to exit if it was the first character typed on the command-line. If there are still jobs running in the background or stopped, gsh will display the message "There are stopped jobs". If you press CTRL-D a second time without an intervening command, gsh will terminate all the jobs in the job list and exit. CTRL-R redraw Moves to the next line and re-displays the current command-line. Use this to redraw the current line if the screen becomes garbled. CTRL-L clear-screen Clears the screen, moves the cursor to the top line, and redraws the prompt and any command-line that was in the process of being edited.
Command Editing These command-line editor keys allow editing of the command-line text. CTRL-B LEFT-ARROW backward-char Moves the cursor one character to the left. You cannot move past the first character on the line. If so, gsh will output an error beep. CTRL-F RIGHT-ARROW forward-char Moves the cursor one character to the right. You cannot move past the last character on the line. If so, gsh will output an error beep. DELETE backward-delete-char Deletes the character to the left of the cursor. You can delete up to the first character on the command-line. CLEAR CTRL-X kill-whole-line Deletes all characters on the command line and positions the cursor after the prompt. CTRL-Y kill-end-of-line Deletes all characters from the cursor to the end of the command-line. CTRL-D OA-D delete-char Deletes the character under the cursor. CTRL-A OA-< beginning-of-line Moves the cursor to the beginning of the line. CTRL-E OA-> end-of-line Moves the cursor to the first position past the last character on the line. OA-RIGHT-ARROW forward-word Moves the cursor right to the last character of the current word. OA-LEFT-ARROW backward-word Moves the cursor left to the beginning of the current word. OA-E toggle-cursor Toggles input mode between insert and overstrike. Overstrike mode is distinguished by a solid inverse cursor and insert mode by a blinking '_' (underscore) cursor. In overstrike mode, any characters that are typed directly over-write those characters below the cursor. In insert mode, the characters typed are inserted before the character below the cursor.
History Editing These command-line editor keys allow access to previously entered commands. The GNO shell automatically keeps track of previous commands in what is called a history buffer. The maximum number of command-lines saved in the history buffer is determined by the shell variable . A default value for this variable is set in the gshrc file that the GNO Installer creates. The lines saved to the history buffer are kept between sessions. That is, when you exit gsh, $SAVEHIST command-lines are saved to your $HOME/history file. When gsh is invoked again, all command-lines saved in the history buffer will be available using history editing keys. See for more information on the HISTORY and SAVEHIST shell variables. CTRL-P UP-ARROW up-history Fetches the previous command-line. If the current command-line is the first line in the history buffer, the next line fetched will be an empty command-line. If invoked again, the last line in the history buffer will be displayed. CTRL-N DOWN-ARROW down-history Fetches the next command-line. If the current command-line is the last command line in the history buffer, the next line fetched will be the first command-line in the history buffer.
Command, Filename, and Variable Completion These command-line editor keys can be used to complete filenames, commands and variables. CTRL-D list-choices Lists commands and pathnames that match the current word. TAB complete-word Command, pathname and variable completion. If the cursor is positioned on the first word of the command-line, command pathname is performed, else pathname or variable completion is performed. The word is expanded to the closest matching command, pathname or variable. Characters are appended up to the point that they would cause more than one. If a complete pathname results for pathname completion, gsh appends a "/" if the pathname is a directory; otherwise, it appends a space. Note that if there is more than one match for the partial command, gsh will sound a beep on the speaker. You can use the CTRL-D (list-choices) command to see the list of possible matches, and should either finish entering the command manually or type enough additional characters to guarantee a unique match. If the FIGNORE environment variable is set, gsh ignores filenames (when doing completion) that end with any of the suffixes in $FIGNORE. See for more information regarding the FIGNORE environment variable.
Other Ways of Entering Commands
Terminal Input An example involving the connection of a terminal will be shown in but it is necessary to mention here that when using gsh over a terminal, some keystrokes must be slightly modified. This is because there are no terminals that can transmit the OA key. Instead, a two-key sequence must be used which replaces OA with ESC. For example, instead of pressing OA-E to toggle insert mode, you can type ESC-E over a terminal to do the same thing. If you will be using terminals seriously then you should install the Remote Access package.
Script File While you would normally type commands on the command-line, you can also store a series of often used commands in a file. A file containing such a series of commands is called a script. A script is normally created by using a text editor. By typing the name of the script file, the shell will execute it, line by line, as if you had typed each command separately. The gshrc file presented in is an example of a script file.