01/02/90 working_dir, wd, print_wdir, pwd

Syntax as a command:  wd {LOCATIONS} {-control_arg}


Syntax as an active function:  [wd {LOCATIONS}]


Function:  prints or returns the pathname of the current working
directory.  Optional arguments can be given to print or return
entries on the stack of working directories.  Refer to the
change_wdir command for a description of the working directory
stack.


Arguments:
LOCATIONS
   select entries on the working directory stack to be printed
   or returned.  LOCATION can be an integer position N from the
   top of the stack; or a text LABEL associated with a stack
   entry; or one of the reserved words first (f), last (l) or
   all (a).  The reserved word first identifies the current
   working directory (which is not on the stack of prior working
   directories and is displayed above stack position 1); last
   identifies the bottom stack entry; and all identifies the
   current working directory plus all stacked directories.


   More than one LOCATION can be given to select several entries.
   Individual locations are separated by a space.  A LOCATION_RANGE
   is given by a starting and ending LOCATION separated by a colon.
   For example, f:2 identifies the current working directory and
   the top two directories on the stack, and 1:XXX identifies stack
   entries from the top of the stack to the entry with label XXX.


Control arguments:
-header, -he
   displays a heading of the form: LOC LABEL PATHNAME .  The default
   is to print a heading when more than one directory is displayed.
-no_header, -nhe
   suppresses the heading before the stack contents are displayed.
   [default]


Notes: Since the working_dir is returned in quotes, the command
processor treats it as a single argument regardless of special
characters in the name.

The current working directory is located at location zero.  The most
recent prior working directory is at the stack position 1 and the
least recent prior working directory is at the Nth (last position).
If a stack of prior working directories is empty then only the current
working directory is printed.  For the case when the current working
directory has been deleted, an attempt to print it out will display
the "directory has been deleted" message in square brackets,
separated from the directory pathname by a blank space.  This does not
apply when one or more prior working directories on the stack have
been deleted.  See also the change_wdir (cwd) command for stack
features.


Examples:  Assume the stack looks like the following:

   0     >udd>m>tai>archive_dev
   1     >udd>m>tai>abbrev_dev
   2 XXX >udd>m>tai>cwd_dev
   3     >udd>m>tai

then

   ! wd XXX
   2 XXX >udd>m>tai>cwd_dev


   ! wd 2 -he
   LOC LABEL PATHNAME

     2 XXX >udd>m>tai>cwd_dev

   ! wd f:XXX
   LOC LABEL PATHNAME

     0     >udd>m>tai>archive_dev
     1     >udd>m>tai>abbrev_dev
     2 XXX >udd>m>tai>cwd_dev

   ! string [wd XXX]
   >udd>m>tai>cwd_dev


   ! string [wd 2]
   >udd>m>tai>cwd_dev


   ! string [wd a]
   >udd>m>tai>archive_dev >udd>m>tai>abbrev_dev >udd>m>tai>cwd_dev >udd>m>tai

   ! dd >udd>m>tai>archive_dev
   ! wd a
   LOC LABEL PATHNAME


     0     >udd>m>tai>archive_dev [directory has been deleted]
     1     >udd>m>tai>abbrev_dev
     2 XXX >udd>m>tai>cwd_dev
     3     >udd>m>tai

   ! string [wd a]
   >udd>m>tai>archive_dev >udd>m>tai>abbrev_dev >udd>m>tai>cwd_dev >udd>m>tai

