PEXEC(1P)
NAME
pexec − execute command over project hierarchy
SYNOPSIS
pexec [−?ciqx] [−P pdirname] [−T typexpr] [−X errstatus] command
DESCRIPTION
Pexec descends recursively through a project hierarchy executing command in each project directory using either the csh or sh command interpreter. The directories at each level are traversed in alphabetical order.
Before executing command in each directory, the current working project is reset to the project in which the directory resides.
Unless the −i option is used, pexec quits if a directory is inaccessible or command returns a non-zero exit status. This prevents propagation of errors through a project.
Care should be taken when using the characters $ * [ | ( ) and \ in the command as they are also meaningful to the command shell. It is safest to enclose the entire command in single quotes.
If a typexpr boolean type label expression is specified, pexec considers only those project directories with type labels that satisfy that expression. The order in which the project directories are traversed depends on the relative priorities of the type labels attached to each directory. Only those type labels that appear in typexpr are used. Directories with labels of the same priority are sorted alphabetically. For example, if the project directories ‘include’, ‘cmd1’, ‘cmd2’, ‘lib1’, and ‘lib2’ have the following labels:
includeprint.0, src, update.0, include
cmd1print.1, src, update.2, cmdsrc
cmd2print.1, src, update.2, cmdsrc
lib1print.2, src, update.1, libsrc
lib2print.2, src, update.1, libsrc
then type label expression ‘update’ will force pexec to traverse the directories in the order ‘include’, ‘lib1’, ‘lib2’, ‘cmd1’, ‘cmd2’.
Labels that are part of a negated expression are not used for sorting.
OPTIONS
−?Do not print “Do you really want to quit? [yn](y):” when interrupted in foreground mode. Quit immediately.
−cInstruct csh to read the ‘.cshrc’ startup file.
−iIgnore inaccessible directories and non-zero exit codes from command.
−qQuiet mode. Do not print ‘==> directory <==’ titles.
−xTrace, and print directory titles, but do not execute command.
−P pdirname
Specify a project other than the current working project. If pdirname is a project directory, command will be executed only in that directory.
−T typexpr
Only execute command in project directories corresponding to boolean type label expression, typexpr.
−X errstatus
If pexec fails, exit with status errstatus. Default error status is 1.
EXAMPLES
To list all of the files in a project using ls, type:
pexec ls
If the directories containing source code have been labeled previously as type ‘src’, then, to count the total number of lines of source code in a project, type:
pexec −Tsrc ´cat *.h *.c´ | wc −l
where quotes surround the cat command to prevent file name expansion in the current directory.
ENVIRONMENT VARIABLES
PROJECTCurrent working project root directory.
SHELLName of command interpreter.
SEE ALSO
DIAGNOSTICS
If pexec is interrupted while executing command in foreground, the message, “Do you really want to quit? [yn](y):” will appear after command has completed.
If the error message, “pexec: label, label ...: conflicting type label priorities”, occurs when performing an operation on a set of project directories that have been selected according to a boolean type label expression with more than one type label, this indicates that the directories cannot be sorted satisfactorily because of a clash in priorities. For example, if project directories a and b, selected by type label expression ‘print&update’, have the following type labels:
directory a:print.1, src, update.2
directory b:print.2, src, update.1
the ordering will be ab if the directories are sorted according to the ‘print’ type label, and ba if they are sorted by the ‘update’ type label. The −D debug option can be used to dump the list of project directories that match typexpr, together with their type labels.
Pexec returns the exit status of command. Exit status 0 is normal. Non-zero exit status indicates an error.
AUTHOR
Peter J. Nicklin
BUGS
The PROJECT environment variable must be defined.
Since pexec uses a separate command shell to execute command in each directory, the characters $ * [ | ( ) and \ will be meaningful to that shell even if command is protected by single quotes.