Welcome | spec | C-PLOT | Support | Users | Contact
 
Contents -> USER MANUAL AND TUTORIALS -> Introduction To the spec User Interface -> UNIX Commands
spec Manual


1.3.9. - UNIX Commands



The easiest way to write macro definitions is to use a standard text editor to create a command file, and the easiest way to get at the text editor is through the unix() function that spawns subshells.
    1.FOURC> unix("vi macro.defs")
    "macro.defs" 3 lines, 20 characters 2.FOURC> qdo macro.defs
    Opened input file `macro.defs' at level 1. 3.FOURC>

Any UNIX command may be spawned as in the above example. Because this is so useful, a macro has been written to simplify the syntax. You could type:
    1.FOURC> u vi macro.defs
    "macro.defs" 3 lines, 20 characters 2.FOURC> qdo macro.defs
    Opened input file `macro.defs' at level 1. 3.FOURC>

The unix() command (or the u macro) with no argument will spawn a subshell. You return to spec upon exiting the subshell. spec uses the shell environment variable SHELL or shell, if set, to select the type of UNIX shell. By default, /bin/sh is used. With arguments, unix() uses /bin/sh to execute the one-line command. For some common UNIX commands, macros such as the following are defined in the standard library.
    def cat 'unix("cat $*")'
    def ls  'unix("ls $*")'
    def l   'unix("ls -l $*")'
    def vi  'unix("vi $*")'
    


The working directory of spec can be changed as with the shell.
    1.FOURC> cd data
    Now in `data' 2.FOURC>

The macro cd used above is defined using the built-in function chdir(). Only the working directory of the program spec is changed; the shell from which you started spec is not touched.


  Top
  Prev | Next