tcl.!.unix Verb: Access/TCL


Command tcl.!.unix Verb: Access/TCL
Applicable release versions: AP/Unix
Category TCL (746)
Description creates a Unix shell and executes any Unix command.

"Unix.command" is any Unix command. A shell is created and the command submitted to it. If "Unix.command" is omitted, a 'shell is pushed'. Pick messages are held until "Unix.command" is complete. If more than one message is received, only the last one is displayed when returning to TCL.

Each time the "!" or "sh" command is invoked, a new shell is "pushed" on "top" of TCL. Control is transferred to this shell. "<ctrl>+d" returns control to TCL.

Note that the form "!Unix.command" does not require a space after the "!".

Macros in the master dictionary make almost all Unix commands available from Pick. The following are a few useful tips on using this facility:

Avoid Creating an Intermediate Shell Process
The "sh" command uses the system(3S) Unix library call to execute the Unix command. This command creates a new process which executes the default shell /bin/sh and passes the string to this new shell. In turn, this new process creates another shell process which does an exec(2) of the Unix command. The intermediate process (the one created by system(3S) is normally useless. The following macro structure avoids the creation of a third process:

01 n
02 !exec command

The "exec shell command" replaces the second process.

Environment Variables:
Upon creation, a shell inherits environment variables from the Pick process. It is possible to change any variable in the macro itself. Consider the following example:

01 n
02 !cd /usr/mydir; TERM=ibm3151; export TERM; exec sh

This macro changes the default directory, sets a new (unix) term type and finally exec a shell. By typing 'env' in this new shell, the new setting will be shown. To permanently set environment variables, use the TCL "environ" command.
Syntax !{Unix.command}
sh {Unix.command}
Related macros