home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / prodtool / util2 / cdx.cmd < prev    next >
Encoding:
Text File  |  1991-05-09  |  2.4 KB  |  61 lines

  1. /*============================================================================*
  2.  * REXX command: cdx - Change directory (extended).
  3.  *
  4.  * (C)Copyright IBM Corporation, 1991.                           Brian E. Yoder
  5.  *
  6.  * This program is a loose adaptation of the AIX 'cd' command.  It is an
  7.  * extended version of OS/2's CD command.  See CDX.DOC file for information.
  8.  *
  9.  * The 'cdir' command is required within the current path.
  10.  *
  11.  * The performance isn't snappy -- AIX shell scripts, although admittedly
  12.  * arcane in syntax, are absolutely astonishingly blindingly fast when
  13.  * compared to REXX/BATCH files on OS/2.
  14.  *
  15.  * 04/30/91 - Created for OS/2.
  16.  * 04/30/91 - Initial version 1.0.
  17.  *============================================================================*/
  18.  "@echo off"
  19.  
  20. /*----------------------------------------------------------------------------*
  21.  * Store first argument: d:path of new directory
  22.  *----------------------------------------------------------------------------*/
  23.  parse arg newdir .
  24.  
  25. /*----------------------------------------------------------------------------*
  26.  * Create a private queue.  Be sure it has nothing in it.
  27.  *----------------------------------------------------------------------------*/
  28.  rc=rxqueue("delete", cdir_q)
  29.  qname=rxqueue("create", cdir_q)
  30.  oldq=rxqueue("set", qname)
  31.  
  32. /*----------------------------------------------------------------------------*
  33.  * Run the 'cdir' command.  It will put a line on the queue as follows:
  34.  *    newpath  newdrive
  35.  *
  36.  *    The name of the c:path to change to is 'newpath'.  The (optional)
  37.  *    drive to change to is 'newdrive'.
  38.  *
  39.  * If cdir fails, it sends no output to stdout.
  40.  *----------------------------------------------------------------------------*/
  41.  cmd = "cdir" newdir "| rxqueue cdir_q /fifo"
  42.  cmd
  43.  
  44. /*----------------------------------------------------------------------------*
  45.  * Get the output from the queue
  46.  *----------------------------------------------------------------------------*/
  47.  if queued() then
  48.  do
  49.     parse pull cdirout
  50.     parse value cdirout with newpath newdrive
  51.  
  52.     "cd" newpath
  53.     newdrive
  54.     return(0)
  55.  end
  56.  
  57. /*----------------------------------------------------------------------------*
  58.  * If we got here, then 'cdir' sent nothing to stdout, so an error occurred.
  59.  *----------------------------------------------------------------------------*/
  60.  return(2)
  61.