LENS

Getting Started: Commands and the Shell


When a command that is typed to the shell or invoked in a script is not immediately recognized, Lens makes several attempts to resolve the problem. First, it checks if the name is an alias for another command (or another command plus a series of arguments) and runs that if found. Aliases are established with the alias command. This is not a normal part of Tcl but was added for Lens.

If the name was not an alias, the interpreter checks if the name is a valid executable. If so, the program is automatically exec'ed with the same stdin and stdout as the current process. Therefore, there should be relatively few situations in which you will actually need to use exec. Simple things like using more, cat, rm, or echo can all be done almost as if you were in your normal shell, except for file name globbing, for which you need to use the glob command. exec will be needed when an executable has the same name as a Lens command or when you want to set up some fancier piping or redirection, particularly if you want to store the output of the command in a variable rather than have it print to stdout. The manual page on exec explains how to use pipes and redirection.

If the unknown command is not an executable, Lens will check if it is a special history command. As in most shells, !! will repeat the most recent command. However, !! must be at the beginning of the command. It cannot appear just anywhere in the command as it can in some shells. !<pat> will repeat the last command that begins with the string <pat>. Finally ^<pat>^<sub> will replace the first occurrence of <pat> in the previous command with <sub> and execute the new command. <pat> and <sub> must be simple strings, not regular expressions.

Next, Lens will check if the command name is a unique substring of a known command. If so, the command name will be completed. If the name is a substring of several commands, those commands will be listed. Lens should treat commands in scripts the same way it treats commands typed directly to the shell. This is not true of Tcl in general.

Invoking any command, other than built-in Tcl commands, with a single "-h" argument will list the help page for that command. "help <command>" will give the same information.

A script file containing a procedure definition need not be explicitly sourced to run the procedure. The procedure will be automatically loaded provided the directory containing the script is on the auto_path and there is a .tclIndex file in the directory storing the location of the procedure. The .tclIndex is built with the index command. More is said on this topic in the section on Script Files.

Typing Ctrl-C in the shell during an ongoing process, such as training, testing, loading example files, or opening the Link Viewer will halt that process. If Ctrl-C is typed when there is no ongoing process, Lens will ask you if you want to exit.


Douglas Rohde
Last modified: Mon Mar 1 23:56:18 EST 1999