home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / SH164X.ZIP / PATCHES.OS2 < prev    next >
Text File  |  1991-02-20  |  68KB  |  2,871 lines

  1. Only in os2/SRC: dir.c
  2. Only in os2/SRC: dir.h
  3. Only in os2/SRC: isfat.c
  4. Only in os2/SRC: jobs.c
  5. Only in os2/SRC: sh.cs
  6. Only in os2/SRC: sh.def
  7. diff -cbBwr orig/SRC/sh.h os2/SRC/sh.h
  8. *** orig/SRC/sh.h    Wed Feb 20 21:24:34 1991
  9. --- os2/SRC/sh.h    Wed Feb 20 20:36:22 1991
  10. ***************
  11. *** 96,102 ****
  12.   #define HISTORY_MAX    100    /* History array length            */
  13.                   /* Space for full file name        */
  14.   #define FFNAME_MAX    (PATH_MAX + NAME_MAX + 4)
  15. ! #define CMD_LINE_MAX    127    /* Max command line length        */
  16.   #define SSAVE_IO_SIZE    4    /* Save IO array malloc increment    */
  17.   
  18.   #define    NPUSH        8    /* limit to input nesting        */
  19. --- 96,102 ----
  20.   #define HISTORY_MAX    100    /* History array length            */
  21.                   /* Space for full file name        */
  22.   #define FFNAME_MAX    (PATH_MAX + NAME_MAX + 4)
  23. ! #define CMD_LINE_MAX    2048    /* Max command line length        */
  24.   #define SSAVE_IO_SIZE    4    /* Save IO array malloc increment    */
  25.   
  26.   #define    NPUSH        8    /* limit to input nesting        */
  27. ***************
  28. *** 109,114 ****
  29. --- 109,116 ----
  30.   #define SP        ' '
  31.   #define    NOT        '^'
  32.   
  33. + #define BATCHEXT        ".cmd"
  34.   /* Here we introduce a new boolean value - MAYBE.  This is required for
  35.    * a special case of the grave function
  36.    */
  37. ***************
  38. *** 190,235 ****
  39.   
  40.   #define    FEXEC        0x0001    /* execute without forking        */
  41.   
  42. - /* MSDOS Memory Control Block chain structure */
  43. - #pragma pack (1)
  44. - struct MCB_list    {
  45. -     char        MCB_type;    /* M or Z            */
  46. -     unsigned int    MCB_pid;    /* Process ID            */
  47. -     unsigned int    MCB_len;    /* MCB length            */
  48. - };
  49. - #pragma pack ()
  50. - #define MCB_CON        'M'        /* More MCB's            */
  51. - #define MCB_END        'Z'        /* Last MCB's            */
  52. - /* Externs for Swapper assembler function */
  53. - extern char        cmd_line[];    /* Command line            */
  54. - extern char        path_line[];    /* Process path            */
  55.   extern unsigned int    SW_intr;    /* interrupt pending        */
  56. - extern unsigned int    SW_Blocks;    /* Number of blocks to read    */
  57. - extern unsigned int    SW_SBlocks;    /* Short Number of blocks to    */
  58. -                     /* read                */
  59. - extern int        SW_fp;        /* File or EMS Handler        */
  60. - extern int        SW_Pwrite;    /* Partial write to disk?    */
  61. - extern unsigned long    SW_EMstart;    /* Start addr of extend mem    */
  62. - extern unsigned int    SW_Mode;    /* Type of swapping to do    */
  63. -                     /* 1 - disk            */
  64. -                     /* 2 - Extended    memory        */
  65. -                     /* 3 - EMS Driver        */
  66. -                     /* 4 - XMS Driver        */
  67. - extern unsigned int    SW_EMSFrame;    /* EMS Frame segment        */
  68. - extern unsigned int    etext;        /* End of text segment        */
  69. - extern int        Swap_Mode;    /* Swapping mode        */
  70. - /* If you change these values, change sh7, swap_device as well */
  71. - #define SWAP_OFF    0x0000        /* No swapping            */
  72. - #define SWAP_DISK    0x0001        /* Disk only            */
  73. - #define SWAP_EXTEND    0x0002        /* Extended memory        */
  74. - #define SWAP_EXPAND    0x0004        /* Expanded memory        */
  75.   
  76.   /*
  77.    * flags to control evaluation of words
  78. --- 192,198 ----
  79. ***************
  80. *** 651,673 ****
  81.   extern void    Clear_Extended_File (void);
  82.   extern void    Print_Version (int);
  83.   extern bool    anys (char *, char *);
  84. - extern void    Clear_Swap_File (void);
  85.   extern C_Op    *Copy_Function (C_Op *);
  86.   extern void    Convert_Backslashes (char *);
  87. - /*
  88. -  * Interrupt handling
  89. -  */
  90. - extern void interrupt    SW_Int24 (void);    /* Int 24 New address    */
  91. - extern void (interrupt far *SW_I0_V) (void);    /* Int 0 address    */
  92. - extern void (interrupt far *SW_I23_V) (void);    /* Int 23 address    */
  93. - /*
  94. -  * XMS Driver functions
  95. -  */
  96. - extern void (far *SW_XMS_Driver) (void);    /* XMS Driver Interface    */
  97. - extern int        SW_XMS_Gversion (void);
  98. - extern int        SW_XMS_Allocate (unsigned int);
  99. - extern int        SW_XMS_Free (int);
  100. --- 614,618 ----
  101. diff -cbBwr orig/SRC/sh1.c os2/SRC/sh1.c
  102. *** orig/SRC/sh1.c    Wed Feb 20 21:24:52 1991
  103. --- os2/SRC/sh1.c    Wed Feb 20 21:05:12 1991
  104. ***************
  105. *** 93,103 ****
  106.   #include <ctype.h>
  107.   #include <fcntl.h>
  108.   #include <limits.h>
  109. ! #include <dirent.h>
  110.   #include <dos.h>
  111.   #include <time.h>
  112.   #include "sh.h"
  113.   
  114.   /*
  115.    * Structure of Malloced space to allow release of space nolonger required
  116.    * without having to know about it.
  117. --- 93,108 ----
  118.   #include <ctype.h>
  119.   #include <fcntl.h>
  120.   #include <limits.h>
  121. ! #include <dir.h>
  122.   #include <dos.h>
  123.   #include <time.h>
  124.   #include "sh.h"
  125.   
  126. + #define INCL_NOPM
  127. + #define INCL_DOSPROCESS
  128. + #define INCL_DOSERRORS
  129. + #include <os2.h>
  130.   /*
  131.    * Structure of Malloced space to allow release of space nolonger required
  132.    * without having to know about it.
  133. ***************
  134. *** 136,143 ****
  135.   static char    *Path       = "PATH";
  136.                   /* Entry directory            */
  137.   static char    *Start_directory = (char *)NULL;
  138. -                     /* Original Interrupt 24 address */
  139. - static void    (interrupt far *Orig_I24_V) (void);
  140.   #ifdef SIGQUIT
  141.   static void    (*qflag)(int) = SIG_IGN;
  142.   #endif
  143. --- 141,146 ----
  144. ***************
  145. *** 154,159 ****
  146. --- 157,165 ----
  147.   static void    Load_G_VL (void);
  148.   static void    Load_profiles (void);
  149.   static void    U2D_Path (void);
  150. + static void     dowaits(int);
  151. + unsigned int SW_intr;
  152.   
  153.   /*
  154.    * The main program starts here
  155. ***************
  156. *** 333,338 ****
  157. --- 339,346 ----
  158.       }
  159.   
  160.       onecommand ();
  161. +         dowaits(0);  /* wait for ending async. processes */
  162.       }
  163.   }
  164.   
  165. ***************
  166. *** 486,491 ****
  167. --- 494,550 ----
  168.       }
  169.   }
  170.   
  171. + /*
  172. +  * look for any ending childs
  173. +  */
  174. + static void dowaits(int mode)
  175. + {
  176. +   RESULTCODES rc;
  177. +   PID pid;
  178. +   char buffer[32];
  179. +   USHORT res;
  180. +   USHORT wmode = DCWW_NOWAIT;
  181. +   for (;;)
  182. +   {
  183. +     res = DosCwait(DCWA_PROCESS, wmode, &rc, &pid, 0);
  184. +     if ( mode && (res == ERROR_CHILD_NOT_COMPLETE) )
  185. +     {
  186. +       S_puts("(Waiting for childs)\n");
  187. +       wmode = DCWW_WAIT;
  188. +       continue;
  189. +     }
  190. +     else
  191. +       if ( res )
  192. +         break;
  193. +     sprintf(buffer, "[%u] ", pid);
  194. +     S_puts(buffer);
  195. +     switch (rc.codeTerminate)
  196. +     {
  197. +     case TC_EXIT:
  198. +       sprintf(buffer, "Done (%u)\n", rc.codeResult);
  199. +       S_puts(buffer);
  200. +       break;
  201. +     case TC_HARDERROR:
  202. +       S_puts("Terminated\n");
  203. +       break;
  204. +     case TC_TRAP:
  205. +       sprintf(buffer, "Trap %d\n", rc.codeResult);
  206. +       S_puts(buffer);
  207. +       break;
  208. +     case TC_KILLPROCESS:
  209. +       S_puts("Killed\n");
  210. +       break;
  211. +     }
  212. +   }
  213. + }
  214.   /*
  215.    * Terminate current environment with an error
  216.    */
  217. ***************
  218. *** 506,516 ****
  219. --- 565,577 ----
  220.       if (execflg)
  221.       fail ();
  222.   
  223. + #if 0
  224.       if (Orig_I24_V == (void (far *)())NULL)
  225.       {
  226.       S_puts ("sh: ignoring attempt to leave lowest level shell\n");
  227.       fail ();
  228.       }
  229. + #endif
  230.   
  231.   /* Clean up */
  232.   
  233. ***************
  234. *** 521,526 ****
  235. --- 582,591 ----
  236.   
  237.       runtrap (0);
  238.   
  239. + /* wait for running bg processes */
  240. +     dowaits(1);
  241.   /* Dump history on exit */
  242.   
  243.   #ifndef NO_HISTORY
  244. ***************
  245. *** 530,539 ****
  246.   
  247.       closeall ();
  248.   
  249. - /* Clear swap file if necessary */
  250. -     Clear_Swap_File ();
  251.   /* If this is a command only - restore the directory because DOS doesn't
  252.    * and the user might expect it
  253.    */
  254. --- 595,600 ----
  255. ***************
  256. *** 552,558 ****
  257.    * Output warning message
  258.    */
  259.   
  260. ! void    print_warn (fmt)
  261.   char    *fmt;
  262.   {
  263.       va_list    ap;
  264. --- 613,619 ----
  265.    * Output warning message
  266.    */
  267.   
  268. ! void    print_warn (fmt, ...)
  269.   char    *fmt;
  270.   {
  271.       va_list    ap;
  272. ***************
  273. *** 573,579 ****
  274.    * Output error message
  275.    */
  276.   
  277. ! void    print_error (fmt)
  278.   char    *fmt;
  279.   {
  280.       va_list    ap;
  281. --- 634,640 ----
  282.    * Output error message
  283.    */
  284.   
  285. ! void    print_error (fmt, ...)
  286.   char    *fmt;
  287.   {
  288.       va_list    ap;
  289. ***************
  290. *** 719,729 ****
  291.       signal (SIGINT, onintr);
  292.       SW_intr = 1;
  293.   
  294. - /* Zap the swap file, just in case it got corrupted */
  295. -     S_close (SW_fp, TRUE);
  296. -     Clear_Swap_File ();
  297.   /* Are we talking to the user?  Yes - check in parser */
  298.   
  299.       if (talking)
  300. --- 780,785 ----
  301. ***************
  302. *** 766,771 ****
  303. --- 822,828 ----
  304.   
  305.   char        *strsave (s, a)
  306.   register char    *s;
  307. + int a;
  308.   {
  309.       register char    *cp;
  310.   
  311. ***************
  312. *** 788,798 ****
  313.       if (i == SIGINT)        /* Need this because swapper sets it    */
  314.       {
  315.       SW_intr = 0;
  316. - /* Zap the swap file, just in case it got corrupted */
  317. -     S_close (SW_fp, TRUE);
  318. -     Clear_Swap_File ();
  319.       }
  320.   
  321.       trapset = i;
  322. --- 845,850 ----
  323. ***************
  324. *** 1569,1583 ****
  325.   void    put_prompt (s)
  326.   char    *s;
  327.   {
  328. !     struct dosdate_t     d_date;
  329. !     struct dostime_t    d_time;
  330.       int    i;
  331.       char buf[PATH_MAX + 4];
  332.   
  333.       last_prompt = s;        /* Save the Last prompt output        */
  334.   
  335. !     _dos_gettime (&d_time);    /* Get the date and time in case    */
  336. !     _dos_getdate (&d_date);
  337.   
  338.       while (*s)
  339.       {
  340. --- 1621,1635 ----
  341.   void    put_prompt (s)
  342.   char    *s;
  343.   {
  344. !     time_t ti;
  345. !     struct tm *tl;
  346.       int    i;
  347.       char buf[PATH_MAX + 4];
  348.   
  349.       last_prompt = s;        /* Save the Last prompt output        */
  350.   
  351. !     time(&ti);
  352. !     tl = localtime(&ti);
  353.   
  354.       while (*s)
  355.       {
  356. ***************
  357. *** 1605,1617 ****
  358.               break;
  359.   
  360.               case 't':            /* time        */
  361. !             sprintf (buf,"%.2d:%.2d", d_time.hour, d_time.minute);
  362.               break;
  363.   
  364.               case 'd':            /* date        */
  365.               sprintf (buf, "%.3s %.2d-%.2d-%.2d",
  366. !                  &"SunMonTueWedThuFriSat"[d_date.dayofweek * 3],
  367. !                  d_date.day, d_date.month, d_date.year % 100);
  368.               break;
  369.   
  370.               case 'p':            /* directory    */
  371. --- 1657,1669 ----
  372.               break;
  373.   
  374.               case 't':            /* time        */
  375. !             sprintf (buf,"%.2d:%.2d", tl -> tm_hour, tl -> tm_min);
  376.               break;
  377.   
  378.               case 'd':            /* date        */
  379.               sprintf (buf, "%.3s %.2d-%.2d-%.2d",
  380. !                  &"SunMonTueWedThuFriSat"[tl -> tm_wday * 3],
  381. !                  tl -> tm_mday, tl -> tm_mon, tl -> tm_year % 100);
  382.               break;
  383.   
  384.               case 'p':            /* directory    */
  385. ***************
  386. *** 1624,1630 ****
  387.               break;
  388.   
  389.               case 'v':            /* version        */
  390. !             sprintf (buf, "MS-DOS %.2d:%.2d", _osmajor, _osminor);
  391.               break;
  392.           }
  393.   
  394. --- 1676,1682 ----
  395.               break;
  396.   
  397.               case 'v':            /* version        */
  398. !             sprintf (buf, "%.2d.%.2d", _osmajor, _osminor);
  399.               break;
  400.           }
  401.   
  402. ***************
  403. *** 1682,1688 ****
  404.   {
  405.       register char    *s, *s1;
  406.       char        **ap;
  407. !     Var_List        *lset;
  408.       bool        l_rflag = FALSE;
  409.   
  410.   /* Patch the ctype table as a cheat */
  411. --- 1734,1740 ----
  412.   {
  413.       register char    *s, *s1;
  414.       char        **ap;
  415. !     Var_List        *lset, *init;
  416.       bool        l_rflag = FALSE;
  417.   
  418.   /* Patch the ctype table as a cheat */
  419. ***************
  420. *** 1693,1701 ****
  421.    * address
  422.    */
  423.   
  424. -     Orig_I24_V = _dos_getvect (0x24);
  425. -     _dos_setvect (0x24, SW_Int24);
  426.   /* Load the environment into our structures */
  427.   
  428.       if ((ap = environ) != (char **)NULL)
  429. --- 1745,1750 ----
  430. ***************
  431. *** 1772,1777 ****
  432. --- 1821,1829 ----
  433.   /* Set up home directory */
  434.   
  435.       if ((lset = lookup (home, TRUE))->value == null)
  436. +       if ((init = lookup ("INIT", TRUE))->value != null)
  437. +     setval (lset, init->value);
  438. +       else
  439.       setval (lset, C_dir->value);
  440.   
  441.       s_vstatus (lset, EXPORT);
  442. ***************
  443. *** 1793,1799 ****
  444.       setval (ifs, " \t\n");
  445.   
  446.       if (ps1->value == null)
  447. !     setval (ps1, "$ ");
  448.   
  449.       if (ps2->value == null)
  450.       setval (ps2, "> ");
  451. --- 1845,1851 ----
  452.       setval (ifs, " \t\n");
  453.   
  454.       if (ps1->value == null)
  455. !     setval (ps1, "%e$ ");
  456.   
  457.       if (ps2->value == null)
  458.       setval (ps2, "> ");
  459. ***************
  460. *** 1895,1902 ****
  461.   static void    Pre_Process_Argv (argv)
  462.   char        **argv;
  463.   {
  464. !     char    *ocl = (char far *)((((long)_psp) << 16) + 0x081L);
  465.   
  466.   
  467.   /* Check for these options */
  468.   
  469. --- 1947,1957 ----
  470.   static void    Pre_Process_Argv (argv)
  471.   char        **argv;
  472.   {
  473. !     extern      char far *_pgmptr;
  474. !     char    *ocl = _pgmptr;
  475.   
  476. +     ocl = strchr(ocl, 0) + 1;
  477. +     ocl = strchr(ocl, 0) + 1;
  478.   
  479.   /* Check for these options */
  480.   
  481. ***************
  482. *** 1964,1969 ****
  483. --- 2019,2025 ----
  484.   {
  485.       char    *name;
  486.       int        f;
  487. +     char        prof[128], *env;
  488.   
  489.   /* Set up home profile */
  490.   
  491. ***************
  492. *** 1982,1987 ****
  493. --- 2038,2057 ----
  494.       {
  495.       PUSHIO (afile, remap (f), filechar);
  496.       }
  497. +     if ( (env = getenv("INIT")) != NULL )
  498. +       if ((f = O_for_execute (strcat(strcpy(prof, env), "/profile"),
  499. +                               (char **)NULL, (int *)NULL)) >= 0)
  500. +       {
  501. +           PUSHIO (afile, remap (f), filechar);
  502. +       }
  503. +     if ( (env = getenv("HOME")) != NULL )
  504. +       if ((f = O_for_execute (strcat(strcpy(prof, env), "/profile"),
  505. +                               (char **)NULL, (int *)NULL)) >= 0)
  506. +       {
  507. +           PUSHIO (afile, remap (f), filechar);
  508. +       }
  509.   }
  510.   
  511.   /*
  512. diff -cbBwr orig/SRC/sh10.c os2/SRC/sh10.c
  513. *** orig/SRC/sh10.c    Wed Feb 20 21:25:34 1991
  514. --- os2/SRC/sh10.c    Wed Feb 20 20:22:46 1991
  515. ***************
  516. *** 37,43 ****
  517.   #include <sys/stat.h>
  518.   #include <stdio.h>
  519.   #include <process.h>
  520. - #include <dos.h>
  521.   #include <signal.h>
  522.   #include <errno.h>
  523.   #include <setjmp.h>
  524. --- 37,42 ----
  525. ***************
  526. *** 47,53 ****
  527.   #include <stdlib.h>
  528.   #include <fcntl.h>
  529.   #include <limits.h>
  530. ! #include <dirent.h>
  531.   #include "sh.h"
  532.   
  533.   
  534. --- 46,52 ----
  535.   #include <stdlib.h>
  536.   #include <fcntl.h>
  537.   #include <limits.h>
  538. ! #include <dir.h>
  539.   #include "sh.h"
  540.   
  541.   
  542. diff -cbBwr orig/SRC/sh2.c os2/SRC/sh2.c
  543. *** orig/SRC/sh2.c    Wed Feb 20 21:25:20 1991
  544. --- os2/SRC/sh2.c    Wed Feb 20 20:22:32 1991
  545. ***************
  546. *** 42,47 ****
  547. --- 42,48 ----
  548.   
  549.   #include <sys/types.h>
  550.   #include <stddef.h>
  551. + #include <stdio.h>
  552.   #include <signal.h>
  553.   #include <errno.h>
  554.   #include <setjmp.h>
  555. ***************
  556. *** 49,55 ****
  557.   #include <ctype.h>
  558.   #include <unistd.h>
  559.   #include <limits.h>
  560. ! #include <dirent.h>
  561.   #include "sh.h"
  562.   
  563.   /*
  564. --- 50,56 ----
  565.   #include <ctype.h>
  566.   #include <unistd.h>
  567.   #include <limits.h>
  568. ! #include <dir.h>
  569.   #include "sh.h"
  570.   
  571.   /*
  572. ***************
  573. *** 557,562 ****
  574. --- 558,564 ----
  575.   }
  576.   
  577.   static C_Op    *block (type, t1, t2, wp)
  578. + int             type;
  579.   C_Op        *t1, *t2;
  580.   char        **wp;
  581.   {
  582. diff -cbBwr orig/SRC/sh3.c os2/SRC/sh3.c
  583. *** orig/SRC/sh3.c    Wed Feb 20 21:25:00 1991
  584. --- os2/SRC/sh3.c    Wed Feb 20 20:58:50 1991
  585. ***************
  586. *** 115,121 ****
  587.   #include <sys/stat.h>
  588.   #include <stdio.h>
  589.   #include <process.h>
  590. - #include <dos.h>
  591.   #include <signal.h>
  592.   #include <errno.h>
  593.   #include <setjmp.h>
  594. --- 115,120 ----
  595. ***************
  596. *** 125,135 ****
  597.   #include <stdlib.h>
  598.   #include <fcntl.h>
  599.   #include <limits.h>
  600. ! #include <dirent.h>
  601.   #include <ctype.h>
  602.   
  603.   #include "sh.h"
  604.   
  605.   /* static Function and string declarations */
  606.   
  607.   static int    forkexec (C_Op *, int, int, int, char **);
  608. --- 124,138 ----
  609.   #include <stdlib.h>
  610.   #include <fcntl.h>
  611.   #include <limits.h>
  612. ! #include <dir.h>
  613.   #include <ctype.h>
  614.   
  615.   #include "sh.h"
  616.   
  617. + #define INCL_NOPM
  618. + #define INCL_DOS
  619. + #include <os2.h>
  620.   /* static Function and string declarations */
  621.   
  622.   static int    forkexec (C_Op *, int, int, int, char **);
  623. ***************
  624. *** 140,151 ****
  625.   static int    rexecve (char *, char **, char **, bool);
  626.   static int    Execute_program (char *, char **, char **, bool);
  627.   static int    S_spawnve (char *, char **, char **);
  628. - static bool    Get_EMS_Driver (void);
  629. - static bool    Get_XMS_Driver (void);
  630. - static bool    EMS_error (char *, int);
  631. - static int    EMS_Close (void);
  632. - static bool    XMS_error (char *, int);
  633. - static int    XMS_Close (void);
  634.   static int    build_command_line (char *, char **, char **);
  635.   static int    setstatus (int);
  636.   static bool    Check_for_bat_file (char *);
  637. --- 143,148 ----
  638. ***************
  639. *** 152,164 ****
  640.   static size_t    white_space_len (char *, bool *);
  641.   static char    *Gen_Full_Path_Name (char *);
  642.   
  643.   static char    *AE2big = "arg/env list too big";
  644. - static char    *EMS_emsg = "Warning: EMS Error (%x)\n";
  645. - static char    *XMS_emsg = "Warning: XMS Error (%x)\n";
  646.   static char    *EF_msg = "%s: %s\n";
  647.               /* Extended Command line processing file name    */
  648.   static char        *Extend_file = (char *)NULL;
  649. - static char        *Swap_File = (char *)NULL;    /* Swap file    */
  650.   
  651.   /*
  652.    * execute tree recursively
  653. --- 149,160 ----
  654.   static size_t    white_space_len (char *, bool *);
  655.   static char    *Gen_Full_Path_Name (char *);
  656.   
  657. + static int      spawnmode = P_WAIT;
  658.   static char    *AE2big = "arg/env list too big";
  659.   static char    *EF_msg = "%s: %s\n";
  660.               /* Extended Command line processing file name    */
  661.   static char        *Extend_file = (char *)NULL;
  662.   
  663.   /*
  664.    * execute tree recursively
  665. ***************
  666. *** 182,187 ****
  667. --- 178,184 ----
  668.       int            Local_depth;        /* Save local values    */
  669.       int            Local_areanum;
  670.       int            rv = 0;
  671. +     int                 readp, writep;
  672.   
  673.   /* End of tree ? */
  674.   
  675. ***************
  676. *** 253,270 ****
  677.           break;
  678.   
  679.       case TPIPE:            /* Pipe processing        */
  680. -         if ((rv = openpipe ()) < 0)
  681. -         break;
  682.   
  683.   /* Create pipe, execute command, reset pipe, execute the other side, close
  684.    * the pipe and fini
  685.    */
  686.           localpipe = remap (rv);
  687.           execute (t->left, pin, localpipe, 0);
  688.           lseek (localpipe, 0L, SEEK_SET);
  689.           rv = execute (t->right, localpipe, pout, 0);
  690.           closepipe (localpipe);
  691.           break;
  692.   
  693.       case TLIST:            /* Entries in a for statement    */
  694. --- 250,298 ----
  695.           break;
  696.   
  697.       case TPIPE:            /* Pipe processing        */
  698.   
  699.   /* Create pipe, execute command, reset pipe, execute the other side, close
  700.    * the pipe and fini
  701.    */
  702. !      /* old DOS version:
  703. !             if ((rv = openpipe ()) < 0)
  704. !         break;
  705.           localpipe = remap (rv);
  706.           execute (t->left, pin, localpipe, 0);
  707.           lseek (localpipe, 0L, SEEK_SET);
  708.           rv = execute (t->right, localpipe, pout, 0);
  709.           closepipe (localpipe);
  710. +          */
  711. +             if (DosMakePipe((PHFILE) &readp, (PHFILE) &writep, 0))
  712. +                 break;
  713. +         readp = remap (readp);
  714. +         writep = remap (writep);
  715. +             DosSetFHandState(readp, OPEN_FLAGS_NOINHERIT);
  716. +         DosSetFHandState(writep, OPEN_FLAGS_NOINHERIT);
  717. +             if ( spawnmode == P_WAIT )
  718. +             {
  719. +               spawnmode = P_NOWAITO;
  720. +           execute (t->left, pin, writep, 0);
  721. +               close(writep);
  722. +               spawnmode = P_NOWAIT;
  723. +           rv = execute (t->right, readp, pout, 0);
  724. +               close(readp);
  725. +               spawnmode = P_WAIT;
  726. +               cwait(&rv, rv, WAIT_GRANDCHILD);
  727. +             }
  728. +             else
  729. +             {
  730. +               rv = spawnmode;
  731. +               spawnmode = P_NOWAITO;
  732. +           execute (t->left, pin, writep, 0);
  733. +               close(writep);
  734. +               spawnmode = rv;
  735. +           rv = execute (t->right, readp, pout, 0);
  736. +               close(readp);
  737. +             }
  738.           break;
  739.   
  740.       case TLIST:            /* Entries in a for statement    */
  741. ***************
  742. *** 272,281 ****
  743.           rv = execute (t->right, pin, pout, 0);
  744.           break;
  745.   
  746. !     case TASYNC:            /* Async - not supported    */
  747. !         rv = -1;
  748.           S_puts ("sh: Async commands not supported\n");
  749.           setstatus (rv);
  750.           break;
  751.   
  752.       case TOR:            /* || and &&            */
  753. --- 300,317 ----
  754.           rv = execute (t->right, pin, pout, 0);
  755.           break;
  756.   
  757. !     case TASYNC:
  758. !      /* rv = -1;
  759.           S_puts ("sh: Async commands not supported\n");
  760.           setstatus (rv);
  761. +          */
  762. +             spawnmode = P_NOWAIT;
  763. +         rv = execute (t->left, pin, pout, 0);
  764. +             spawnmode = P_WAIT;
  765. +             S_puts("[");
  766. +             S_puts(putn(rv));
  767. +             S_puts("]\n");
  768. +             setval (lookup ("!", TRUE), putn (rv));
  769.           break;
  770.   
  771.       case TOR:            /* || and &&            */
  772. ***************
  773. *** 458,464 ****
  774.   {
  775.       unsigned int    dummy;
  776.   
  777. !     _dos_setdrive (tolower(*path) - 'a' + 1, &dummy);
  778.   
  779.       if (chdir (&path[2]) != 0)
  780.       {
  781. --- 494,500 ----
  782.   {
  783.       unsigned int    dummy;
  784.   
  785. !     DosSelectDisk(tolower(*path) - 'a' + 1);
  786.   
  787.       if (chdir (&path[2]) != 0)
  788.       {
  789. ***************
  790. *** 523,529 ****
  791.   
  792.   /* Check for built in commands */
  793.   
  794. !     else if (cp != (char *)NULL)
  795.           shcom = inbuilt (cp, &builtin);
  796.       }
  797.   
  798. --- 559,566 ----
  799.   
  800.   /* Check for built in commands */
  801.   
  802. !     else
  803. !           if (cp != (char *)NULL)
  804.           shcom = inbuilt (cp, &builtin);
  805.       }
  806.   
  807. ***************
  808. *** 531,536 ****
  809. --- 568,574 ----
  810.   
  811.       t->words = wp;
  812.       if ((act & FEXEC) == 0)
  813. +     if (shcom == NULL && (act & FEXEC) == 0)
  814.       {
  815.       spawn = TRUE;
  816.   
  817. ***************
  818. *** 911,918 ****
  819.       int            nargc = 0;        /* # script args    */
  820.       char        *p_name;        /* Program name        */
  821.       int            i;
  822. !     union REGS        r;
  823.   
  824.   /* If the environment is null - It is too big - error */
  825.   
  826.       if (envp == (char **)NULL)
  827. --- 949,963 ----
  828.       int            nargc = 0;        /* # script args    */
  829.       char        *p_name;        /* Program name        */
  830.       int            i;
  831. ! /* Count the number of arguments to the program in case of shell script or
  832. !  * bat file
  833. !  */
  834. !     while (v[argc++] != (char *)NULL);
  835.   
  836. +     ++argc;                /* Including the null        */
  837.   /* If the environment is null - It is too big - error */
  838.   
  839.       if (envp == (char **)NULL)
  840. ***************
  841. *** 921,937 ****
  842.       else if ((p_name = getcell (FFNAME_MAX)) == (char *)NULL)
  843.       em = strerror (ENOMEM);
  844.   
  845. !     else
  846.       {
  847. ! /* Count the number of arguments to the program in case of shell script or
  848. !  * bat file
  849. !  */
  850.   
  851. !     while (v[argc++] != (char *)NULL);
  852. !     ++argc;                /* Including the null        */
  853.   
  854.   /* Start off on the search path for the executable file */
  855.   
  856.       sp = (any ('/', c) || (*(c + 1) == ':')) ? null : path->value;
  857. --- 966,991 ----
  858.       else if ((p_name = getcell (FFNAME_MAX)) == (char *)NULL)
  859.       em = strerror (ENOMEM);
  860.   
  861. !     else if ( c == NULL )
  862.       {
  863. ! /* cmd.exe interal command */
  864.   
  865. !       if ((new_argv = (char **) getcell (sizeof(char *) * (argc + 2)))
  866. !            == NULL)
  867. !       em = strerror (ENOMEM);
  868. !       else
  869. !       {
  870. !         memcpy (&new_argv[2], &v[0], sizeof(char *) * argc);
  871. !         new_argv[0] = lookup ("COMSPEC", FALSE)->value;
  872. !         new_argv[1] = "/c";
  873. !         res = rexecve (new_argv[0], new_argv, envp, d_flag);
  874. !         DELETE (new_argv);
  875. !     return res;
  876. !       }
  877. !     }
  878.   
  879. +     else
  880. +     {
  881.   /* Start off on the search path for the executable file */
  882.   
  883.       sp = (any ('/', c) || (*(c + 1) == ':')) ? null : path->value;
  884. ***************
  885. *** 992,1005 ****
  886.               {
  887.               new_argv[0] = lookup ("COMSPEC", FALSE)->value;
  888.               new_argv[1] = "/c";
  889. - /* Get the switch character */
  890. -             r.x.ax = 0x3700;
  891. -             intdos (&r, &r);
  892. -             if ((r.h.al == 0) && (_osmajor < 4))
  893. -                 *new_argv[1] = (char)(r.h.dl);
  894.               }
  895.   
  896.   /* Stick in the pre-fix arguments */
  897. --- 1046,1051 ----
  898. ***************
  899. *** 1102,1110 ****
  900.       ++cp;
  901.   
  902.       if ((cp = strrchr (cp, '.')) == (char *)NULL)
  903. !     strcat (local_path, ".bat");
  904.   
  905. !     else if (stricmp (cp, ".bat") != 0)
  906.       {
  907.       DELETE (local_path);
  908.       return FALSE;
  909. --- 1148,1156 ----
  910.       ++cp;
  911.   
  912.       if ((cp = strrchr (cp, '.')) == (char *)NULL)
  913. !     strcat (local_path, BATCHEXT);
  914.   
  915. !     else if (stricmp (cp, BATCHEXT) != 0)
  916.       {
  917.       DELETE (local_path);
  918.       return FALSE;
  919. ***************
  920. *** 1215,1225 ****
  921.   char        **parms;
  922.   char        **envp;
  923.   {
  924. !     unsigned int    c_cur = (unsigned int)(_psp - 1);
  925. !     unsigned int    size = 0;
  926. !     char        *ep, *ep1;
  927.       int            res, serrno;
  928. -     struct MCB_list    *mp = (struct MCB_list *)((unsigned long)c_cur << 16L);
  929.   
  930.   /* Check to see if the file exists */
  931.   
  932. --- 1261,1268 ----
  933.   char        **parms;
  934.   char        **envp;
  935.   {
  936. !     char        *ep, *ep1, path_line[255];
  937.       int            res, serrno;
  938.   
  939.   /* Check to see if the file exists */
  940.   
  941. ***************
  942. *** 1256,1636 ****
  943.       else if (access (path_line, F_OK) != 0)
  944.       return -1;
  945.   
  946. ! /* Process the command line.  If no swapping, we have executed the program */
  947. !     res = build_command_line (path_line, parms, envp);
  948. !     if ((Swap_Mode == SWAP_OFF) || res)
  949. !     return res;
  950. ! /* Find the length of the swap area */
  951. !     while ((mp = (struct MCB_list *)((unsigned long)c_cur << 16L))->MCB_type
  952. !         == MCB_CON)
  953. !     {
  954. !     if ((mp->MCB_pid != _psp) && (mp->MCB_pid != 0) &&
  955. !         (mp->MCB_type != MCB_END))
  956. !     {
  957. !         Clear_Extended_File ();
  958. !         print_error ("Fatal: Memory chain corrupt\n");
  959. !         return -1;
  960. !     }
  961. !     c_cur += (mp->MCB_len + 1);
  962. !     size += mp->MCB_len + 1;
  963. !     }
  964. ! /*
  965. !  * Convert swap size from paragraphs to 16K blocks.
  966. !  */
  967. !     if (size == 0)
  968. !     size = mp->MCB_len + 1;
  969. !     SW_Blocks = (size / 0x0400) + 1;
  970. !     SW_SBlocks = ((size - etext + _psp - 1) / 0x0400) + 1;
  971. ! /* OK Now we've set up the FCB's, command line and opened the swap file.
  972. !  * Get some sys info for the swapper and execute my little assembler
  973. !  * function to swap us out
  974. !  */
  975. ! /* Save the interrupt 0 and 23 addresses */
  976. !     SW_I0_V  = _dos_getvect (0x00);
  977. !     SW_I23_V = _dos_getvect (0x23);
  978. ! /* Ok - 3 methods of swapping */
  979. ! /* If expanded memory - try that */
  980. !     if ((Swap_Mode & SWAP_EXPAND) && Get_EMS_Driver ())
  981. !     {
  982. !     int    cr;
  983. !     SW_Mode = 3;            /* Set Expanded memory swap    */
  984. !     res = SA_spawn (envp);
  985. !     cr = EMS_Close ();        /* Close EMS            */
  986. !     if ((res != -2) && cr)        /* Report Close error ?        */
  987. !     {
  988. !         res = -2;
  989. !         errno = cr;
  990. !     }
  991. !     if (res == -2)
  992. !         EMS_error ("Expanded memory swap failed (%x)\n", errno);
  993. !     else
  994. !     {
  995. !         Clear_Extended_File ();
  996. !         return res;
  997. !     }
  998. ! /* Failed - disabled */
  999. !     Swap_Mode &= (~SWAP_EXPAND);
  1000. !     }
  1001. !     if ((Swap_Mode & SWAP_EXTEND) && Get_XMS_Driver ())
  1002. !     {
  1003. !     int    cr;
  1004. ! /* Set Extended memory or XMS driver */
  1005. !     SW_Mode = (SW_fp == -1) ? 2 : 4;
  1006. !     res = SA_spawn (envp);
  1007. !     cr = XMS_Close ();        /* Close XMS            */
  1008. !     if ((res != -2) && cr)        /* Report Close error ?        */
  1009. !     {
  1010. !         res = -2;
  1011. !         errno = cr;
  1012. !     }
  1013. !     if (res == -2)
  1014. !         XMS_error ("Extended memory swap failed (%x)\n", errno);
  1015. !     else
  1016. !     {
  1017. !         Clear_Extended_File ();
  1018. !         return res;
  1019. !     }
  1020. ! /* Failed - disabled */
  1021. !     Swap_Mode &= (~SWAP_EXTEND);
  1022. !     }
  1023. ! /* Try the disk if available */
  1024. !     if (Swap_Mode & SWAP_DISK)
  1025. !     {
  1026. !     SW_Pwrite = 0;
  1027. !     if (Swap_File == (char *)NULL)
  1028. !         SW_fp = S_open (FALSE, (ep = g_tempname ()), O_SMASK, 0600);
  1029. !     else
  1030. !     {
  1031. !         SW_fp = S_open (FALSE, Swap_File, O_SaMASK);
  1032. !         SW_Pwrite = 1;
  1033. !     }
  1034. !     if (SW_fp < 0)
  1035. !     {
  1036. !         Clear_Swap_File ();
  1037. !         Swap_Mode &= (~SWAP_DISK);
  1038. !         print_error ("No Swap files\n");
  1039. !         errno = ENOSPC;
  1040. !         return -1;
  1041. !     }
  1042. ! /* Save the swap file name ? */
  1043. !     if ((Swap_File == (char *)NULL) &&
  1044. !         ((Swap_File = strsave (ep, 0)) == null))
  1045. !         Swap_File = (char *)NULL;
  1046. !     SW_Mode = 1;            /* Set Disk file swap        */
  1047. ! /* Seek to correct location */
  1048. !     if (SW_Pwrite)
  1049. !     {
  1050. !             long    loc = (long)(etext - _psp + 1) * 16L;
  1051. !         if (lseek (SW_fp, loc, SEEK_SET) != loc)
  1052. !         {
  1053. !         serrno = errno;
  1054. !         S_close (SW_fp, TRUE);
  1055. !         Clear_Swap_File ();
  1056. !         Swap_Mode &= (~SWAP_DISK);
  1057. !         print_error ("No Swap files\n");
  1058. !         errno = serrno;
  1059. !         return -1;
  1060. !         }
  1061. !     }
  1062. ! /* Execute the program */
  1063. !     res = SA_spawn (envp);
  1064. ! /* Close the swap file and extended command line files */
  1065. !     Clear_Extended_File ();
  1066. !     serrno = errno;
  1067. !     S_close (SW_fp, TRUE);
  1068. !     errno = serrno;
  1069. ! /* Check for out of swap space */
  1070. !     if (res == -2)
  1071. !     {
  1072. !         Clear_Swap_File ();
  1073. !         Swap_Mode &= (~SWAP_DISK);
  1074. !         print_warn ("Swap file write failed\n");
  1075. !         errno = ENOSPC;
  1076. !         res = -1;
  1077. !     }
  1078. ! /* Return the result */
  1079. !     return res;
  1080. !     }
  1081. ! /* No swapping available - give up */
  1082. !     Clear_Extended_File ();
  1083. !     print_error ("All Swapping methods failed\n");
  1084. !     errno = ENOSPC;
  1085. !     return -1;
  1086. ! }
  1087. ! /* Get the XMS Driver information */
  1088. ! static bool    Get_XMS_Driver ()
  1089. ! {
  1090. !     union REGS        or;
  1091. !     struct SREGS    sr;
  1092. !     unsigned int    SW_EMsize;    /* Number of extend memory blks    */
  1093. ! /* Get max Extended memory pages, and convert to 16K blocks.  If Extended
  1094. !  * memory swapping disabled, set to zero
  1095. !  */
  1096. !     SW_fp = -1;                /* Set EMS/XMS handler not    */
  1097. !                     /* defined            */
  1098. ! /* Is a XMS memory driver installed */
  1099. !     or.x.ax = 0x4300;
  1100. !     int86 (0x2f, &or, &or);
  1101. !     if (or.h.al != 0x80)
  1102. !     {
  1103. !     or.x.ax = 0x8800;
  1104. !     int86 (0x15, &or, &or);
  1105. !     SW_EMsize = or.x.ax / 16;
  1106. !     if ((SW_EMsize <= SW_Blocks) ||
  1107. !          ((SW_EMstart - 0x100000L +
  1108. !           ((long)(SW_Blocks - SW_EMsize) * 16L * 1024L)) < 0L))
  1109. !         return XMS_error ("Not enough Extended memory for swap\n", 0);
  1110. !     else
  1111. !         return TRUE;
  1112. !     }
  1113. ! /* Get the driver interface */
  1114. !     or.x.ax = 0x4310;
  1115. !     int86x (0x2f, &or, &or, &sr);
  1116. !     SW_XMS_Driver = (void (*)())((unsigned long)(sr.es) << 16L | or.x.bx);
  1117. !     if ((SW_XMS_Gversion () & 0xff00) != 0x0200)
  1118. !     return XMS_error ("Warning: XMS Version != 2\n", 0);
  1119. !     else if ((SW_fp = SW_XMS_Allocate (SW_Blocks * 16)) == -1)
  1120. !     return XMS_error (XMS_emsg, errno);
  1121. !     return TRUE;
  1122. ! }
  1123. ! /* Get the EMS Driver information */
  1124. ! static bool    Get_EMS_Driver ()
  1125. ! {
  1126. !     union REGS        or;
  1127. !     struct SREGS    sr;
  1128. !     char        *sp;
  1129. ! /* Set EMS/XMS handler not defined */
  1130. !     SW_fp = -1;
  1131. !     or.x.ax = 0x3567;
  1132. !     intdosx (&or, &or, &sr);
  1133. !     sp = (char *)((unsigned long)(sr.es) << 16L | 10L);
  1134. ! /* If not there - disable */
  1135. !     if (memcmp ("EMMXXXX0", sp, 8) != 0)
  1136. !     return EMS_error ("Warning: EMS not available\n", 0);
  1137.   
  1138. !     or.h.ah = 0x40;            /* Check status            */
  1139. !     int86 (0x67, &or, &or);
  1140. !     if (or.h.ah != 0)
  1141. !     return EMS_error (EMS_emsg, or.h.ah);
  1142. ! /* Check version greater than 3.2 */
  1143. !     or.h.ah = 0x46;
  1144. !     int86 (0x67, &or, &or);
  1145. !     if ((or.h.ah != 0) || (or.h.al < 0x32))
  1146. !     return EMS_error ("Warning: EMS Version < 3.2\n", 0);
  1147. ! /*  get page frame address */
  1148. !     or.h.ah = 0x41;
  1149. !     int86 (0x67, &or, &or);
  1150. !     if (or.h.ah != 0)
  1151. !     return EMS_error (EMS_emsg, or.h.ah);
  1152. !     SW_EMSFrame = or.x.bx;        /* Save the page frame        */
  1153. ! /* Get the number of pages required */
  1154. !     or.h.ah = 0x43;
  1155. !     or.x.bx = SW_Blocks;
  1156. !     int86 (0x67, &or, &or);
  1157. !     if (or.h.ah != 0)
  1158. !     return EMS_error (EMS_emsg, or.h.ah);
  1159. ! /* Save the EMS Handler */
  1160. !     SW_fp = or.x.dx;
  1161. ! /* save EMS page map */
  1162. !     or.h.ah = 0x47;
  1163. !     or.x.dx = SW_fp;
  1164. !     int86 (0x67, &or, &or);
  1165. !     return (or.h.ah != 0) ? EMS_error (EMS_emsg, or.h.ah) : TRUE;
  1166. ! }
  1167. ! /* Print EMS error message */
  1168. ! static bool    EMS_error (s, v)
  1169. ! char        *s;
  1170. ! int        v;
  1171. ! {
  1172. !     print_warn (s, v);
  1173. !     Swap_Mode &= ~(SWAP_EXPAND);
  1174. !     EMS_Close ();
  1175. !     return FALSE;
  1176. ! }
  1177. ! /* Print XMS error message */
  1178. ! static bool    XMS_error (s, v)
  1179. ! char        *s;
  1180. ! int        v;
  1181. ! {
  1182. !     print_warn (s, v);
  1183. !     Swap_Mode &= ~(SWAP_EXTEND);
  1184. !     XMS_Close ();
  1185. !     return FALSE;
  1186. ! }
  1187. ! /* If the XMS handler is defined - close it */
  1188. ! static int    XMS_Close ()
  1189. ! {
  1190. !     int        res = 0;
  1191. ! /* Release XMS page */
  1192. !     if (SW_fp != -1)
  1193. !     res = SW_XMS_Free (SW_fp);
  1194. !     SW_fp = -1;
  1195. !     return res;
  1196. ! }
  1197. ! /* If the EMS handler is defined - close it */
  1198. ! static int    EMS_Close ()
  1199. ! {
  1200. !     union REGS        or;
  1201. !     int            res = 0;
  1202. !     if (SW_fp == -1)
  1203. !     return 0;
  1204. ! /* Restore EMS page */
  1205. !     or.h.ah = 0x48;
  1206. !     or.x.dx = SW_fp;
  1207. !     int86 (0x67, &or, &or);
  1208. !     if (or.h.ah != 0)
  1209. !     res = or.h.al;
  1210. !     or.h.ah = 0x45;
  1211. !     or.x.dx = SW_fp;
  1212. !     int86 (0x67, &or, &or);
  1213. !     SW_fp = -1;
  1214. !     return (res) ? res : or.h.ah;
  1215.   }
  1216.   
  1217.   /* Set up command line.  If the EXTENDED_LINE variable is set, we create
  1218. --- 1299,1307 ----
  1219.       else if (access (path_line, F_OK) != 0)
  1220.       return -1;
  1221.   
  1222. ! /* Process the command line. */
  1223.   
  1224. !     return build_command_line (path_line, parms, envp);
  1225.   }
  1226.   
  1227.   /* Set up command line.  If the EXTENDED_LINE variable is set, we create
  1228. ***************
  1229. *** 1653,1658 ****
  1230. --- 1324,1331 ----
  1231.       bool        found;
  1232.       char        *ep;
  1233.       char        *new_args[3];
  1234. +     char                cmd_line[CMD_LINE_MAX];
  1235. +     void         (*save_signal)(int);
  1236.   
  1237.   /* Translate process name to MSDOS format */
  1238.   
  1239. ***************
  1240. *** 1746,1752 ****
  1241.   
  1242.   /* Correctly terminate cmd_line in no swap mode */
  1243.   
  1244. -         if (Swap_Mode != SWAP_OFF)
  1245.           cmd_line[cmd_line[0] + 2] = '\r';
  1246.   
  1247.   /* If the name in the file is in upper case - use \ for separators */
  1248. --- 1419,1424 ----
  1249. ***************
  1250. *** 1756,1771 ****
  1251.   
  1252.   /* OK we are ready to execute */
  1253.   
  1254. -         if (Swap_Mode == SWAP_OFF)
  1255. -         {
  1256.           new_args[0] = *argv;
  1257.           new_args[1] = &cmd_line[1];
  1258.           new_args[2] = (char *)NULL;
  1259. -         return spawnve (P_WAIT, path, new_args, envp);
  1260. -         }
  1261.   
  1262. !         else
  1263. !         return 0;
  1264.       }
  1265.       }
  1266.   
  1267. --- 1428,1441 ----
  1268.   
  1269.   /* OK we are ready to execute */
  1270.   
  1271.           new_args[0] = *argv;
  1272.           new_args[1] = &cmd_line[1];
  1273.           new_args[2] = (char *)NULL;
  1274.   
  1275. !             save_signal = signal (SIGINT, SIG_DFL);
  1276. !         res = spawnve (spawnmode, path, new_args, envp);
  1277. !             signal (SIGINT, save_signal);
  1278. !             return res;
  1279.       }
  1280.       }
  1281.   
  1282. ***************
  1283. *** 1805,1813 ****
  1284.   
  1285.       cmd_line[0] = (char)res;
  1286.   
  1287. ! /* If swapping disabled - just execute it */
  1288.   
  1289. !     return (Swap_Mode == SWAP_OFF) ? spawnve (P_WAIT, path, argv, envp) : 0;
  1290.   }
  1291.   
  1292.   /* Check string for white space */
  1293. --- 1475,1486 ----
  1294.   
  1295.       cmd_line[0] = (char)res;
  1296.   
  1297. ! /* Just execute it */
  1298.   
  1299. !     save_signal = signal (SIGINT, SIG_DFL);
  1300. !     res = spawnve (spawnmode, path, argv, envp);
  1301. !     signal (SIGINT, save_signal);
  1302. !     return res;
  1303.   }
  1304.   
  1305.   /* Check string for white space */
  1306. ***************
  1307. *** 1844,1862 ****
  1308.       Extend_file = (char *)NULL;
  1309.   }
  1310.   
  1311. - /* Clear Disk swap file file */
  1312. - void    Clear_Swap_File ()
  1313. - {
  1314. -     if (Swap_File != (char *)NULL)
  1315. -     {
  1316. -     unlink (Swap_File);
  1317. -     DELETE (Swap_File);
  1318. -     }
  1319. -     Swap_File = (char *)NULL;
  1320. - }
  1321.   /* Convert the executable path to the full path name */
  1322.   
  1323.   static char    *Gen_Full_Path_Name (path)
  1324. --- 1517,1522 ----
  1325. ***************
  1326. *** 1890,1898 ****
  1327.   
  1328.   /* Switch drives and get the path of the other drive */
  1329.   
  1330. !         _dos_setdrive (tolower (*path) - 'a' + 1, &dummy);
  1331.           getcwd (npath, PATH_MAX + 3);
  1332. !         _dos_setdrive (tolower (*cpath) - 'a' + 1, &dummy);
  1333.        }
  1334.       }
  1335.   
  1336. --- 1550,1558 ----
  1337.   
  1338.   /* Switch drives and get the path of the other drive */
  1339.   
  1340. !         DosSelectDisk(tolower (*path) - 'a' + 1);
  1341.           getcwd (npath, PATH_MAX + 3);
  1342. !         DosSelectDisk(tolower (*cpath) - 'a' + 1);
  1343.        }
  1344.       }
  1345.   
  1346. ***************
  1347. *** 1921,1927 ****
  1348.   /* Change to the directory containing the executable */
  1349.   
  1350.       if (*(path + 1) == ':')
  1351. !         _dos_setdrive (tolower (*path) - 'a' + 1, &dummy);
  1352.   
  1353.   /* Save the current directory on this drive */
  1354.   
  1355. --- 1581,1587 ----
  1356.   /* Change to the directory containing the executable */
  1357.   
  1358.       if (*(path + 1) == ':')
  1359. !         DosSelectDisk(tolower (*path) - 'a' + 1);
  1360.   
  1361.   /* Save the current directory on this drive */
  1362.   
  1363. ***************
  1364. *** 1942,1948 ****
  1365.   
  1366.   /* Restore our original directory */
  1367.   
  1368. !     _dos_setdrive (tolower (*cpath) - 'a' + 1, &dummy);
  1369.   
  1370.       if (chdir (cpath) < 0)
  1371.           return (char *)NULL;
  1372. --- 1602,1608 ----
  1373.   
  1374.   /* Restore our original directory */
  1375.   
  1376. !     DosSelectDisk(tolower (*cpath) - 'a' + 1);
  1377.   
  1378.       if (chdir (cpath) < 0)
  1379.           return (char *)NULL;
  1380. diff -cbBwr orig/SRC/sh4.c os2/SRC/sh4.c
  1381. *** orig/SRC/sh4.c    Wed Feb 20 21:25:06 1991
  1382. --- os2/SRC/sh4.c    Wed Feb 20 20:47:30 1991
  1383. ***************
  1384. *** 59,73 ****
  1385.   #include <signal.h>
  1386.   #include <errno.h>
  1387.   #include <setjmp.h>
  1388. - #include <dirent.h>
  1389.   #include <string.h>
  1390.   #include <stdlib.h>
  1391.   #include <unistd.h>
  1392.   #include <ctype.h>
  1393. - #include <bios.h>
  1394. - #include <dos.h>
  1395.   #include "sh.h"
  1396.   
  1397.   /*
  1398.    * ${}, `command`, blank interpretation, quoting and file name expansion
  1399.    */
  1400. --- 59,76 ----
  1401.   #include <signal.h>
  1402.   #include <errno.h>
  1403.   #include <setjmp.h>
  1404.   #include <string.h>
  1405.   #include <stdlib.h>
  1406. + #include <stdio.h>
  1407.   #include <unistd.h>
  1408. + #include <dir.h>
  1409.   #include <ctype.h>
  1410.   #include "sh.h"
  1411.   
  1412. + #define INCL_NOPM
  1413. + #define INCL_DOS
  1414. + #include <os2.h>
  1415.   /*
  1416.    * ${}, `command`, blank interpretation, quoting and file name expansion
  1417.    */
  1418. ***************
  1419. *** 100,105 ****
  1420. --- 103,109 ----
  1421.   
  1422.   char        **eval(ap, f)
  1423.   register char    **ap;
  1424. + int             f;
  1425.   {
  1426.       Word_B    *wb = (Word_B *)NULL;
  1427.       char    **wp = (char **)NULL;
  1428. ***************
  1429. *** 269,274 ****
  1430. --- 273,279 ----
  1431.    */
  1432.   
  1433.   static char    *blank(f)
  1434. + int             f;
  1435.   {
  1436.       register int    c, c1;
  1437.       register char    *sp = e.linep;
  1438. ***************
  1439. *** 869,875 ****
  1440.       if (any (*pp, spcl))
  1441.           i++;
  1442.   
  1443. !     else if (!any (*pp & ~QUOTE, spcl))
  1444.           *pp &= ~QUOTE;
  1445.       }
  1446.   
  1447. --- 874,880 ----
  1448.       if (any (*pp, spcl))
  1449.           i++;
  1450.   
  1451. !     else if (!any ((char)(*pp & ~QUOTE), spcl))
  1452.           *pp &= ~QUOTE;
  1453.       }
  1454.   
  1455. ***************
  1456. *** 945,951 ****
  1457.   {
  1458.       register char    *np, *cp;
  1459.       char        *name, *gp, *dp;
  1460. !     struct dirent    *d_ce;
  1461.       char        dname[NAME_MAX + 1];
  1462.       struct stat        dbuf;
  1463.   
  1464. --- 950,956 ----
  1465.   {
  1466.       register char    *np, *cp;
  1467.       char        *name, *gp, *dp;
  1468. !     struct direct    *d_ce;
  1469.       char        dname[NAME_MAX + 1];
  1470.       struct stat        dbuf;
  1471.   
  1472. ***************
  1473. *** 990,996 ****
  1474.   
  1475.   /* Scan for matches */
  1476.   
  1477. !     while ((d_ce = readdir (e.cdir)) != (struct dirent *)NULL)
  1478.       {
  1479.        if ((*(strncpy (dname, d_ce->d_name, NAME_MAX)) == '.') && (*gp != '.'))
  1480.             continue;
  1481. --- 995,1001 ----
  1482.   
  1483.   /* Scan for matches */
  1484.   
  1485. !     while ((d_ce = readdir (e.cdir)) != (struct direct *)NULL)
  1486.       {
  1487.        if ((*(strncpy (dname, d_ce->d_name, NAME_MAX)) == '.') && (*gp != '.'))
  1488.             continue;
  1489. ***************
  1490. *** 1030,1036 ****
  1491.       }
  1492.   
  1493.       closedir (e.cdir);
  1494. !     e.cdir = (DIR *)NULL;
  1495.       DELETE (dp);
  1496.       DELETE (gp);
  1497.   }
  1498. --- 1035,1041 ----
  1499.       }
  1500.   
  1501.       closedir (e.cdir);
  1502. !     e.cdir = NULL;
  1503.       DELETE (dp);
  1504.       DELETE (gp);
  1505.   }
  1506. ***************
  1507. *** 1199,1248 ****
  1508.   char        *start;
  1509.   {
  1510.       unsigned int    c_drive;    /* Current drive        */
  1511. -     unsigned int    m_drive;    /* Max drive            */
  1512. -     unsigned int    s_drive;    /* Selected drive        */
  1513. -     unsigned int    x_drive, y_drive;    /* Dummies        */
  1514.       char        *multi;        /* Multi-drive flag        */
  1515.       static char        *t_drive = "x";
  1516.       char        *new_pattern;
  1517.   
  1518.   /* Search all drives ? */
  1519.   
  1520.       if ((multi = Check_Multi_Drive (pattern)) != (char *)NULL)
  1521.       {
  1522. !     _dos_getdrive (&c_drive);    /* Get number of drives        */
  1523. !     _dos_setdrive (c_drive, &m_drive);
  1524. !     new_pattern = space (strlen (multi) + 2);
  1525.   
  1526.       strcpy (new_pattern + 1, multi);
  1527. -     *multi = 0;
  1528.   
  1529. !     for (s_drive = 1; s_drive <= m_drive; ++s_drive)
  1530.         {
  1531. !         _dos_setdrive (s_drive, &x_drive);
  1532. !         _dos_getdrive (&y_drive);
  1533. !         _dos_setdrive (c_drive, &x_drive);
  1534. ! /* Check to see if the second diskette drive is really there */
  1535. !         if (((_bios_equiplist () & 0x00c0) == 0x0000) && (s_drive == 2))
  1536. !         continue;
  1537. ! /* If the drive exists and is in our list - process it */
  1538. !         *t_drive = (char)(s_drive + 'a' - 1);
  1539.   
  1540. !         if ((y_drive == s_drive) &&
  1541. !          gmatch (t_drive, pattern, TRUE, (char **)NULL, GM_ALL))
  1542.             {
  1543.             *new_pattern = *t_drive;
  1544. !         globname (new_pattern, &new_pattern[2]);
  1545.             }
  1546.         }
  1547.   
  1548.   /* Restore and delete space */
  1549.   
  1550. -     *multi = ':';
  1551.       DELETE (new_pattern);
  1552.       }
  1553.   
  1554. --- 1204,1242 ----
  1555.   char        *start;
  1556.   {
  1557.       unsigned int    c_drive;    /* Current drive        */
  1558.       char        *multi;        /* Multi-drive flag        */
  1559.       static char        *t_drive = "x";
  1560.       char        *new_pattern;
  1561. +     ULONG               l_map;
  1562. +     int                 cnt;
  1563.   
  1564.   /* Search all drives ? */
  1565.   
  1566.       if ((multi = Check_Multi_Drive (pattern)) != (char *)NULL)
  1567.       {
  1568. !         DosQCurDisk((PUSHORT) &c_drive, &l_map);
  1569.   
  1570. +     new_pattern = space (strlen (multi) + 2);
  1571.       strcpy (new_pattern + 1, multi);
  1572.   
  1573. !         for ( cnt = 1; cnt <= 26; cnt++, l_map >>= 1 )
  1574. !           if ( l_map & 1L )
  1575.         {
  1576. !           *t_drive = (char)(cnt + 'a' - 1);
  1577. !               *multi = 0;
  1578.   
  1579. !           if (gmatch (t_drive, pattern, TRUE, (char **)NULL, GM_ALL))
  1580.             {
  1581.             *new_pattern = *t_drive;
  1582. !                 *multi = ':';
  1583. !           globname (new_pattern, strchr(new_pattern,0));
  1584.             }
  1585. +               else
  1586. +                 *multi = ':';
  1587.         }
  1588.   
  1589.   /* Restore and delete space */
  1590.   
  1591.       DELETE (new_pattern);
  1592.       }
  1593.   
  1594. diff -cbBwr orig/SRC/sh5.c os2/SRC/sh5.c
  1595. *** orig/SRC/sh5.c    Wed Feb 20 21:21:06 1991
  1596. --- os2/SRC/sh5.c    Fri Sep 07 18:46:04 1990
  1597. ***************
  1598. *** 61,67 ****
  1599.   #include <fcntl.h>
  1600.   #include <io.h>
  1601.   #include <limits.h>
  1602. ! #include <dirent.h>
  1603.   #include <unistd.h>
  1604.   #include "sh.h"
  1605.   
  1606. --- 61,67 ----
  1607.   #include <fcntl.h>
  1608.   #include <io.h>
  1609.   #include <limits.h>
  1610. ! #include <dir.h>
  1611.   #include <unistd.h>
  1612.   #include "sh.h"
  1613.   
  1614. ***************
  1615. *** 875,881 ****
  1616.    * Otherwise, write x
  1617.    */
  1618.   
  1619. !         if ((c & QUOTE) && !any ((c & ~QUOTE), "$`\\"))
  1620.               Add_buffer ('\\', bp);
  1621.   
  1622.           Add_buffer ((char)(c & (~QUOTE)), bp);
  1623. --- 875,881 ----
  1624.    * Otherwise, write x
  1625.    */
  1626.   
  1627. !         if ((c & QUOTE) && !any ((char)(c & ~QUOTE), "$`\\"))
  1628.               Add_buffer ('\\', bp);
  1629.   
  1630.           Add_buffer ((char)(c & (~QUOTE)), bp);
  1631. diff -cbBwr orig/SRC/sh6.c os2/SRC/sh6.c
  1632. *** orig/SRC/sh6.c    Wed Feb 20 21:25:16 1991
  1633. --- os2/SRC/sh6.c    Wed Feb 20 20:48:00 1991
  1634. ***************
  1635. *** 71,83 ****
  1636.   #include <setjmp.h>
  1637.   #include <stdlib.h>
  1638.   #include <limits.h>
  1639. ! #include <dirent.h>
  1640.   #include <unistd.h>
  1641.   #include <string.h>
  1642.   #include "sh.h"
  1643.   
  1644. ! static char    *Copy_Right1 = "MS-DOS SH Version 1.6.4 - %s (DOS %d.%d)\n";
  1645.   static char    *Copy_Right2 = "Copyright (c) Data Logic Ltd and Charles Forsyth 1990\n";
  1646.   char        **dolv;        /* Parameter array            */
  1647.   int        dolc;        /* Number of entries in parameter array    */
  1648.   int        exstat;        /* Exit status                */
  1649. --- 71,86 ----
  1650.   #include <setjmp.h>
  1651.   #include <stdlib.h>
  1652.   #include <limits.h>
  1653. ! #include <proto.h>
  1654. ! #include <dir.h>
  1655.   #include <unistd.h>
  1656.   #include <string.h>
  1657.   #include "sh.h"
  1658.   
  1659. ! static char    *Copy_Right1 = "\nSH Version 1.6.4 - %s (OS/2 %d.%02d)\n";
  1660.   static char    *Copy_Right2 = "Copyright (c) Data Logic Ltd and Charles Forsyth 1990\n";
  1661. + static char    *Copy_Right3 = "Ported to OS/2 by Kai Uwe Rommel 1990\n\n";
  1662.   char        **dolv;        /* Parameter array            */
  1663.   int        dolc;        /* Number of entries in parameter array    */
  1664.   int        exstat;        /* Exit status                */
  1665. ***************
  1666. *** 90,96 ****
  1667.   int        *failpt;    /* Current fail point jump address    */
  1668.   int        *errpt;        /* Current error point jump address    */
  1669.                   /* Swap mode                */
  1670. - int        Swap_Mode = SWAP_EXPAND | SWAP_DISK;
  1671.   Break_C        *Break_List;    /* Break list for FOR/WHILE        */
  1672.   Break_C        *Return_List;    /* Return list for RETURN        */
  1673.   Break_C        *SShell_List;    /* SubShell list for EXIT        */
  1674. --- 93,98 ----
  1675. ***************
  1676. *** 169,175 ****
  1677.   {
  1678.       char    buf[100];
  1679.   
  1680. !     sprintf (buf, Copy_Right1, __DATE__, _osmajor, _osminor);
  1681.       write (fp, buf, strlen (buf));
  1682.       write (fp, Copy_Right2, strlen (Copy_Right2));
  1683.   }
  1684. --- 171,178 ----
  1685.   {
  1686.       char    buf[100];
  1687.   
  1688. !     sprintf (buf, Copy_Right1, __DATE__, _osmajor / 10, _osminor);
  1689.       write (fp, buf, strlen (buf));
  1690.       write (fp, Copy_Right2, strlen (Copy_Right2));
  1691. +     write (fp, Copy_Right3, strlen (Copy_Right3));
  1692.   }
  1693. diff -cbBwr orig/SRC/sh7.c os2/SRC/sh7.c
  1694. *** orig/SRC/sh7.c    Wed Feb 20 21:25:28 1991
  1695. --- os2/SRC/sh7.c    Wed Feb 20 21:30:10 1991
  1696. ***************
  1697. *** 88,94 ****
  1698.   #include <sys/stat.h>
  1699.   #include <stdio.h>
  1700.   #include <process.h>
  1701. - #include <dos.h>
  1702.   #include <signal.h>
  1703.   #include <errno.h>
  1704.   #include <setjmp.h>
  1705. --- 88,93 ----
  1706. ***************
  1707. *** 98,107 ****
  1708.   #include <stdlib.h>
  1709.   #include <fcntl.h>
  1710.   #include <limits.h>
  1711. ! #include <dirent.h>
  1712.   #include <stdarg.h>
  1713.   #include "sh.h"
  1714.   
  1715.   #define    SECS        60L
  1716.   #define    MINS        3600L
  1717.   #define IS_OCTAL(a)    (((a) >= '0') && ((a) <= '7'))
  1718. --- 97,110 ----
  1719.   #include <stdlib.h>
  1720.   #include <fcntl.h>
  1721.   #include <limits.h>
  1722. ! #include <dir.h>
  1723.   #include <stdarg.h>
  1724.   #include "sh.h"
  1725.   
  1726. + #define INCL_NOPM
  1727. + #define INCL_DOS
  1728. + #include <os2.h>
  1729.   #define    SECS        60L
  1730.   #define    MINS        3600L
  1731.   #define IS_OCTAL(a)    (((a) >= '0') && ((a) <= '7'))
  1732. ***************
  1733. *** 112,118 ****
  1734.   #define FILE_READABLE    1
  1735.   #define FILE_WRITABLE    2
  1736.   #define FILE_REGULAR    3
  1737. ! #define FILE_DIRECTORY    4
  1738.   #define FILE_NONZERO    5
  1739.   #define FILE_TERMINAL    6
  1740.   #define STRING_ZERO    7
  1741. --- 115,121 ----
  1742.   #define FILE_READABLE    1
  1743.   #define FILE_WRITABLE    2
  1744.   #define FILE_REGULAR    3
  1745. ! #define _FILE_DIRECTORY    4
  1746.   #define FILE_NONZERO    5
  1747.   #define FILE_TERMINAL    6
  1748.   #define STRING_ZERO    7
  1749. ***************
  1750. *** 154,160 ****
  1751.       {"-w",    FILE_WRITABLE,        UNARY_OP},
  1752.       {"-x",    FILE_EXECUTABLE,    UNARY_OP},
  1753.       {"-f",    FILE_REGULAR,        UNARY_OP},
  1754. !     {"-d",    FILE_DIRECTORY,        UNARY_OP},
  1755.       {"-s",    FILE_NONZERO,        UNARY_OP},
  1756.       {"-t",    FILE_TERMINAL,        UNARY_OP},
  1757.       {"-z",    STRING_ZERO,        UNARY_OP},
  1758. --- 157,163 ----
  1759.       {"-w",    FILE_WRITABLE,        UNARY_OP},
  1760.       {"-x",    FILE_EXECUTABLE,    UNARY_OP},
  1761.       {"-f",    FILE_REGULAR,        UNARY_OP},
  1762. !     {"-d",    _FILE_DIRECTORY,    UNARY_OP},
  1763.       {"-s",    FILE_NONZERO,        UNARY_OP},
  1764.       {"-t",    FILE_TERMINAL,        UNARY_OP},
  1765.       {"-z",    STRING_ZERO,        UNARY_OP},
  1766. ***************
  1767. *** 190,196 ****
  1768.   #ifdef S_IFIFO
  1769.       {"-p",    FILE_FIFO,        UNARY_OP},
  1770.   #endif
  1771. !     {(char *)NULL,    NULL,        NULL}
  1772.   };
  1773.   
  1774.   static int        expr (int);
  1775. --- 193,199 ----
  1776.   #ifdef S_IFIFO
  1777.       {"-p",    FILE_FIFO,        UNARY_OP},
  1778.   #endif
  1779. !     {(char *)NULL,    0,        0}
  1780.   };
  1781.   
  1782.   static int        expr (int);
  1783. ***************
  1784. *** 208,214 ****
  1785.   static int        doecho (C_Op *);
  1786.   static int        dogetopt (C_Op *);
  1787.   static int        dopwd (C_Op *);
  1788. - static int        doswap (C_Op *);
  1789.   static int        dounset (C_Op *);
  1790.   static int        dotype (C_Op *);
  1791.   static int        dotest (C_Op *);
  1792. --- 211,216 ----
  1793. ***************
  1794. *** 229,234 ****
  1795. --- 231,239 ----
  1796.   static int        doreadonly (C_Op *);
  1797.   static int        doset (C_Op *);
  1798.   static int        dohistory (C_Op *);
  1799. + extern int              dojobs(C_Op *);
  1800. + extern int              docls(C_Op *);
  1801.   static void        setsig (int, int (*)());
  1802.   static int        rdexp (char **, int, char *);
  1803.   
  1804. ***************
  1805. *** 466,588 ****
  1806.   }
  1807.   
  1808.   /*
  1809. !  * Display the current version
  1810.    */
  1811.   
  1812. ! static int    dover (t)
  1813.   C_Op        *t;
  1814.   {
  1815. -     Print_Version (1);
  1816.       return 0;
  1817.   }
  1818.   
  1819. - static char    *swap_device[] = {"disk", "extend", "expand"};
  1820.   /*
  1821. !  * Modify swapping information: swap options
  1822.    */
  1823.   
  1824. ! static int    doswap (t)
  1825. ! register C_Op    *t;
  1826. ! {
  1827. !     register int    n = 1;
  1828. !     char        *cp;
  1829. ! /* Display current values ? */
  1830. !     if (t->words[1] == (char *)NULL)
  1831. !     {
  1832. !     if (Swap_Mode == SWAP_OFF)
  1833. !         v1a_puts ("Swapping disabled");
  1834. !     else
  1835. !     {
  1836. !         register int    j;
  1837. !         v1_puts ("Swap devices: ");
  1838. !         for (j = 0, n = 1; j < 3; ++j, n <<= 1)
  1839. !         {
  1840. !         if (Swap_Mode & n)
  1841. !         {
  1842. !             v1printf ("%s ", swap_device[j]);
  1843. !             if (n == SWAP_EXTEND)
  1844. !             v1printf ("(0x%.6lx) ", SW_EMstart);
  1845. !         }
  1846. !         }
  1847. !         v1_putc (NL);
  1848. !     }
  1849. !     return 0;
  1850. !     }
  1851. ! /* Set up new values */
  1852. !     Swap_Mode = SWAP_OFF;
  1853. !     Clear_Swap_File ();
  1854. !     while ((cp = t->words[n++]) != (char *)NULL)
  1855. ! {
  1856. !     if (strcmp (cp, "off") == 0)
  1857. !         Swap_Mode = SWAP_OFF;
  1858. !     else if (strcmp (cp, "on") == 0)
  1859. !         Swap_Mode = SWAP_DISK | SWAP_EXPAND | SWAP_EXTEND;
  1860. ! /* Scan for valid arguments */
  1861. !     else
  1862. !     {
  1863. !         register int    j, k;
  1864. !         for (j = 0, k = 1; j < 3; ++j, k <<= 1)
  1865. !         {
  1866. !         if (strcmp (cp, swap_device[j]) == 0)
  1867. !         {
  1868. !             Swap_Mode |= k;
  1869. ! /* If extended memory, they can specify the start address as a hex number */
  1870. !             if (k == SWAP_EXTEND)
  1871.               {
  1872. !             char    *sp;
  1873. !             long    start;
  1874. ! /* Check for not changed */
  1875. !             if ((sp = t->words[n]) == (char *)NULL)
  1876. !                 break;
  1877. ! /* Convert hex number */
  1878. !             start = strtol (sp, &sp, 16);
  1879. ! /* If not completely a hex number, ignore */
  1880. !             if (*sp)
  1881. !                 break;
  1882. ! /* Set used and saved new value */
  1883. !             SW_EMstart = start;
  1884. !             ++n;
  1885. !             if ((SW_EMstart < 0x100000L) ||
  1886. !                 (SW_EMstart > 0xf00000L))
  1887. !                 SW_EMstart = 0x100000L;
  1888. !             v1printf ("Extend memory start set to 0x%.6lx\n",
  1889. !                   SW_EMstart);
  1890. !             }
  1891. !             break;
  1892. !         }
  1893. !         }
  1894. !     }
  1895. !     }
  1896.       return 0;
  1897.   }
  1898.   
  1899. --- 471,493 ----
  1900.   }
  1901.   
  1902.   /*
  1903. !  * Do nothing
  1904.    */
  1905.   
  1906. ! static int    donothing (t)
  1907.   C_Op        *t;
  1908.   {
  1909.       return 0;
  1910.   }
  1911.   
  1912.   /*
  1913. !  * Display the current version
  1914.    */
  1915.   
  1916. ! static int    dover (t)
  1917. ! C_Op        *t;
  1918.   {
  1919. !     Print_Version (1);
  1920.       return 0;
  1921.   }
  1922.   
  1923. ***************
  1924. *** 859,865 ****
  1925.       case FILE_REGULAR:
  1926.           return stat (*test_alist, &s) == 0 && S_ISREG(s.st_mode);
  1927.   
  1928. !     case FILE_DIRECTORY:
  1929.           return stat (*test_alist, &s) == 0 && S_ISDIR(s.st_mode);
  1930.   
  1931.       case FILE_NONZERO:
  1932. --- 764,770 ----
  1933.       case FILE_REGULAR:
  1934.           return stat (*test_alist, &s) == 0 && S_ISREG(s.st_mode);
  1935.   
  1936. !     case _FILE_DIRECTORY:
  1937.           return stat (*test_alist, &s) == 0 && S_ISDIR(s.st_mode);
  1938.   
  1939.       case FILE_NONZERO:
  1940. ***************
  1941. *** 961,970 ****
  1942.   {
  1943.       unsigned int    cdrive;
  1944.       unsigned int    ndrive = tolower (**t->words) - 'a' + 1;
  1945.   
  1946. !     _dos_setdrive (ndrive, &cdrive);
  1947.       Getcwd ();
  1948. !     _dos_getdrive (&cdrive);
  1949.       return (ndrive == cdrive) ? 0 : 1;
  1950.   }
  1951.   
  1952. --- 866,876 ----
  1953.   {
  1954.       unsigned int    cdrive;
  1955.       unsigned int    ndrive = tolower (**t->words) - 'a' + 1;
  1956. +     ULONG l_map;
  1957.   
  1958. !     DosSelectDisk(ndrive);
  1959.       Getcwd ();
  1960. !     DosQCurDisk((PUSHORT) &cdrive, &l_map);
  1961.       return (ndrive == cdrive) ? 0 : 1;
  1962.   }
  1963.   
  1964. ***************
  1965. *** 982,987 ****
  1966. --- 888,894 ----
  1967.       int            first = 0;
  1968.       unsigned int    dummy;
  1969.       unsigned int    cdrive;
  1970. +     ULONG l_map;
  1971.   
  1972.   /* If restricted shell - illegal */
  1973.   
  1974. ***************
  1975. *** 1005,1011 ****
  1976.   
  1977.   /* Save the current drive */
  1978.   
  1979. !     _dos_getdrive (&cdrive);
  1980.   
  1981.   /* Scan for the directory.  If there is not a / or : at start, use the
  1982.    * CDPATH variable
  1983. --- 912,918 ----
  1984.   
  1985.   /* Save the current drive */
  1986.   
  1987. !     DosQCurDisk((PUSHORT) &cdrive, &l_map);
  1988.   
  1989.   /* Scan for the directory.  If there is not a / or : at start, use the
  1990.    * CDPATH variable
  1991. ***************
  1992. *** 1024,1030 ****
  1993.   
  1994.       if (*(nd + 1) == ':')
  1995.       {
  1996. !         _dos_setdrive (tolower (*nd) - 'a' + 1, &dummy);
  1997.           nd += 2;
  1998.       }
  1999.   
  2000. --- 931,937 ----
  2001.   
  2002.       if (*(nd + 1) == ':')
  2003.       {
  2004. !         DosSelectDisk(tolower (*nd) - 'a' + 1);
  2005.           nd += 2;
  2006.       }
  2007.   
  2008. ***************
  2009. *** 1051,1057 ****
  2010.   
  2011.   /* Restore our original drive and restore directory info */
  2012.   
  2013. !     _dos_setdrive (cdrive, &dummy);
  2014.       Getcwd ();
  2015.   
  2016.       print_error ("%s: bad directory\n", p);
  2017. --- 958,964 ----
  2018.   
  2019.   /* Restore our original drive and restore directory info */
  2020.   
  2021. !     DosSelectDisk(cdrive);
  2022.       Getcwd ();
  2023.   
  2024.       print_error ("%s: bad directory\n", p);
  2025. ***************
  2026. *** 1773,1779 ****
  2027.    */
  2028.   
  2029.   static char    *type_ext[] = {
  2030. !     "", ".exe", ".com", ".sh", ".bat"
  2031.   };
  2032.   
  2033.   static int    dotype (t)
  2034. --- 1680,1686 ----
  2035.    */
  2036.   
  2037.   static char    *type_ext[] = {
  2038. !     "", ".exe", ".com", ".sh", BATCHEXT
  2039.   };
  2040.   
  2041.   static int    dotype (t)
  2042. ***************
  2043. *** 1803,1809 ****
  2044.   
  2045.       while ((cp = t->words[n++]) != (char *)NULL)
  2046.       {
  2047. !     if ( inbuilt (cp) )
  2048.           {
  2049.           v1_puts (cp);
  2050.           v1a_puts (" is a shell internal command");
  2051. --- 1710,1719 ----
  2052.   
  2053.       while ((cp = t->words[n++]) != (char *)NULL)
  2054.       {
  2055. ! /* Check for currently use inbuilt version */
  2056. !     if (inbuilt (cp, &inb) && inb)
  2057.       {
  2058.           v1_puts (cp);
  2059.           v1a_puts (" is a shell internal command");
  2060. ***************
  2061. *** 1861,1869 ****
  2062.   
  2063.               else if ((stricmp (xp, ".exe") != 0) &&
  2064.                    (stricmp (xp, ".com") != 0) &&
  2065. !                  (stricmp (xp, ".bat") != 0))
  2066.               continue;
  2067.   
  2068.               Convert_Backslashes (strlwr (l_path));
  2069.               print_error ("%s is %s\n", cp, l_path);
  2070.               found = TRUE;
  2071. --- 1770,1779 ----
  2072.   
  2073.               else if ((stricmp (xp, ".exe") != 0) &&
  2074.                    (stricmp (xp, ".com") != 0) &&
  2075. !                  (stricmp (xp, BATCHEXT) != 0))
  2076.               continue;
  2077.   
  2078. +                     strlwr(l_path);
  2079.               Convert_Backslashes (strlwr (l_path));
  2080.               print_error ("%s is %s\n", cp, l_path);
  2081.               found = TRUE;
  2082. ***************
  2083. *** 1898,1903 ****
  2084. --- 1808,1814 ----
  2085.       "break",    dobreak,    BLT_CURRENT,
  2086.       "builtin",    dobuiltin,    (BLT_ALWAYS | BLT_CURRENT),
  2087.       "cd",        dochdir,    BLT_CURRENT,
  2088. +     "cls",        docls,          BLT_CURRENT,
  2089.       "continue",    docontinue,    BLT_CURRENT,
  2090.       "echo",        doecho,        BLT_CURRENT,
  2091.       "eval",        doeval,        BLT_CURRENT,
  2092. ***************
  2093. *** 1904,1913 ****
  2094. --- 1815,1826 ----
  2095.       "exec",        doexec,        BLT_CURRENT,
  2096.       "exit",        doexit,        BLT_CURRENT,
  2097.       "export",    doexport,    BLT_CURRENT,
  2098. +         "extproc",      donothing,      BLT_CURRENT,
  2099.       "getopt",    dogetopt,    BLT_CURRENT,
  2100.   #ifndef NO_HISTORY
  2101.       "history",    dohistory,    BLT_CURRENT,
  2102.   #endif
  2103. +         "jobs",         dojobs,         BLT_CURRENT,
  2104.       "msdos",    domsdos,    BLT_CURRENT,
  2105.       "pwd",        dopwd,        BLT_CURRENT,
  2106.       "read",        doread,        BLT_CURRENT,
  2107. ***************
  2108. *** 1915,1921 ****
  2109.       "return",    doreturn,    BLT_CURRENT,
  2110.       "set",        doset,        BLT_CURRENT,
  2111.       "shift",    doshift,    BLT_CURRENT,
  2112. -     "swap",        doswap,        BLT_CURRENT,
  2113.       "test",        dotest,        BLT_CURRENT,
  2114.       "trap",        dotrap,        BLT_CURRENT,
  2115.       "type",        dotype,        BLT_CURRENT,
  2116. --- 1828,1833 ----
  2117. ***************
  2118. *** 1962,1968 ****
  2119.    * Equivalent of printf without using streams
  2120.    */
  2121.   
  2122. ! void    v1printf (fmt)
  2123.   char    *fmt;
  2124.   {
  2125.       va_list    ap;
  2126. --- 1874,1880 ----
  2127.    * Equivalent of printf without using streams
  2128.    */
  2129.   
  2130. ! void    v1printf (fmt, ...)
  2131.   char    *fmt;
  2132.   {
  2133.       va_list    ap;
  2134. diff -cbBwr orig/SRC/sh8.c os2/SRC/sh8.c
  2135. *** orig/SRC/sh8.c    Wed Feb 20 21:25:10 1991
  2136. --- os2/SRC/sh8.c    Wed Feb 20 20:22:18 1991
  2137. ***************
  2138. *** 61,66 ****
  2139. --- 61,67 ----
  2140.   #include <errno.h>
  2141.   #include <setjmp.h>
  2142.   #include <stdlib.h>
  2143. + #include <stdio.h>
  2144.   #include <fcntl.h>
  2145.   #include <io.h>
  2146.   #include <stdarg.h>
  2147. ***************
  2148. *** 67,73 ****
  2149.   #include <string.h>
  2150.   #include <unistd.h>
  2151.   #include <limits.h>
  2152. ! #include <dirent.h>
  2153.   #include <ctype.h>
  2154.   #include "sh.h"
  2155.   
  2156. --- 68,74 ----
  2157.   #include <string.h>
  2158.   #include <unistd.h>
  2159.   #include <limits.h>
  2160. ! #include <dir.h>
  2161.   #include <ctype.h>
  2162.   #include "sh.h"
  2163.   
  2164. ***************
  2165. *** 97,103 ****
  2166.    * for a normal open.
  2167.    */
  2168.   
  2169. ! int    S_open (d_flag, name, mode)
  2170.   bool    d_flag;
  2171.   char    *name;
  2172.   int    mode;
  2173. --- 98,104 ----
  2174.    * for a normal open.
  2175.    */
  2176.   
  2177. ! int    S_open (d_flag, name, mode, ...)
  2178.   bool    d_flag;
  2179.   char    *name;
  2180.   int    mode;
  2181. ***************
  2182. *** 598,604 ****
  2183.   /* Try the file name and then with a .sh appended */
  2184.   
  2185.       if ((i = Check_Script (strcpy (local_path, path), params, nargs)) < 0)
  2186. !     i = Check_Script (strcat (local_path, ".sh"), params, nargs);
  2187.   
  2188.       DELETE (local_path);
  2189.       return i;
  2190. --- 599,606 ----
  2191.   /* Try the file name and then with a .sh appended */
  2192.   
  2193.       if ((i = Check_Script (strcpy (local_path, path), params, nargs)) < 0)
  2194. !       if ((i = Check_Script (strcat (local_path, ".sh"), params, nargs)) == 0)
  2195. !         strcpy(path, local_path);
  2196.   
  2197.       DELETE (local_path);
  2198.       return i;
  2199. diff -cbBwr orig/SRC/sh9.c os2/SRC/sh9.c
  2200. *** orig/SRC/sh9.c    Wed Feb 20 21:21:22 1991
  2201. --- os2/SRC/sh9.c    Mon Sep 10 12:19:18 1990
  2202. ***************
  2203. *** 74,84 ****
  2204.   #include <errno.h>
  2205.   #include <setjmp.h>
  2206.   #include <limits.h>
  2207. - #include <dos.h>
  2208.   #include <unistd.h>
  2209. ! #include <dirent.h>
  2210.   #include "sh.h"
  2211.   
  2212.   /* Keyboard functions */
  2213.   
  2214.   #define KF_LENGTH        (sizeof (KF_List) / sizeof (KF_List[0]))
  2215. --- 74,87 ----
  2216.   #include <errno.h>
  2217.   #include <setjmp.h>
  2218.   #include <limits.h>
  2219.   #include <unistd.h>
  2220. ! #include <dir.h>
  2221.   #include "sh.h"
  2222.   
  2223. + #define INCL_NOPM
  2224. + #define INCL_VIO
  2225. + #include <os2.h>
  2226.   /* Keyboard functions */
  2227.   
  2228.   #define KF_LENGTH        (sizeof (KF_List) / sizeof (KF_List[0]))
  2229. ***************
  2230. *** 99,107 ****
  2231.   #define KF_DELETELEFT    0x0e        /* Delete left character    */
  2232.   #define KF_COMPLETE    0x0f        /* Complete file name        */
  2233.   #define KF_DIRECTORY    0x10        /* Complete directory function    */
  2234. ! #define KF_END_FKEYS    0x11        /* End of function keys        */
  2235. ! #define KF_RINGBELL    0x11        /* Ring bell            */
  2236. ! #define KF_HALFHEIGTH    0x12        /* Half height cursor        */
  2237.   
  2238.   /* Function Declarations */
  2239.   
  2240. --- 102,113 ----
  2241.   #define KF_DELETELEFT    0x0e        /* Delete left character    */
  2242.   #define KF_COMPLETE    0x0f        /* Complete file name        */
  2243.   #define KF_DIRECTORY    0x10        /* Complete directory function    */
  2244. ! #define KF_JOBS         0x11            /* Jobs list */
  2245. ! #define KF_CLS          0x12            /* Jobs list */
  2246. ! #define KF_END_FKEYS    0x13        /* End of function keys        */
  2247. ! #define KF_RINGBELL    0x13        /* Ring bell            */
  2248. ! #define KF_HALFHEIGTH    0x14        /* Half height cursor        */
  2249.   
  2250.   /* Function Declarations */
  2251.   
  2252. ***************
  2253. *** 130,136 ****
  2254.   static int    Max_Cols  = 80;        /* Max columns            */
  2255.   static int    Max_Lines = 25;        /* Max Lines            */
  2256.   #ifndef NO_HISTORY
  2257. ! static bool    insert_mode = FALSE;
  2258.   static char    *c_buffer_pos;        /* Position in command line    */
  2259.   static char    *end_buffer;        /* End of command line        */
  2260.   static int    m_line = 0;        /* Max write line number    */
  2261. --- 136,142 ----
  2262.   static int    Max_Cols  = 80;        /* Max columns            */
  2263.   static int    Max_Lines = 25;        /* Max Lines            */
  2264.   #ifndef NO_HISTORY
  2265. ! static bool    insert_mode = TRUE;
  2266.   static char    *c_buffer_pos;        /* Position in command line    */
  2267.   static char    *end_buffer;        /* End of command line        */
  2268.   static int    m_line = 0;        /* Max write line number    */
  2269. ***************
  2270. *** 162,180 ****
  2271.       { "WordRight",    0,    't',    KF_WORDRIGHT },
  2272.       { "WordLeft",    0,    's',    KF_WORDLEFT },
  2273.       { "Start",        0,    'G',    KF_START },
  2274. !     { "Clear",        0,    'v',    KF_CLEAR },
  2275.       { "Flush",        0,    'u',    KF_FLUSH },
  2276.       { "End",        0,    'O',    KF_END },
  2277.       { "Insert",        0,    'R',    KF_INSERT },
  2278.       { "DeleteRight",    0,    'S',    KF_DELETERIGHT },
  2279.       { "DeleteLeft",    0x08,    0,    KF_DELETELEFT },
  2280. !     { "Complete",    0,    'w',    KF_COMPLETE },
  2281.       { "Directory",    0,    0x0f,    KF_DIRECTORY },
  2282.   
  2283.   /* End of function keys - flags */
  2284.   
  2285.       { "Bell",        1,    0,    KF_RINGBELL },
  2286. !     { "HalfHeight",    0,    0,    KF_HALFHEIGTH }
  2287.   };
  2288.   
  2289.   /* Arrary of history Items */
  2290. --- 168,188 ----
  2291.       { "WordRight",    0,    't',    KF_WORDRIGHT },
  2292.       { "WordLeft",    0,    's',    KF_WORDLEFT },
  2293.       { "Start",        0,    'G',    KF_START },
  2294. !     { "Clear",        0x1b,    0,    KF_CLEAR },
  2295.       { "Flush",        0,    'u',    KF_FLUSH },
  2296.       { "End",        0,    'O',    KF_END },
  2297.       { "Insert",        0,    'R',    KF_INSERT },
  2298.       { "DeleteRight",    0,    'S',    KF_DELETERIGHT },
  2299.       { "DeleteLeft",    0x08,    0,    KF_DELETELEFT },
  2300. !     { "Complete",    0x09,    0,    KF_COMPLETE },
  2301.       { "Directory",    0,    0x0f,    KF_DIRECTORY },
  2302. +     { "Jobs",        0,    0x94,    KF_JOBS },
  2303. +     { "ClearScreen",    0x0C,    0,    KF_CLS },
  2304.   
  2305.   /* End of function keys - flags */
  2306.   
  2307.       { "Bell",        1,    0,    KF_RINGBELL },
  2308. !     { "HalfHeight",    1,    0,    KF_HALFHEIGTH }
  2309.   };
  2310.   
  2311.   /* Arrary of history Items */
  2312. ***************
  2313. *** 238,244 ****
  2314.   
  2315.       while (TRUE)
  2316.       {
  2317. !     Init_Input (FALSE);            /* Initialise        */
  2318.   
  2319.       while (((a_key = (char)getch ()) != 0x1a) && (a_key != NL) &&
  2320.           (a_key != '\r'))
  2321. --- 246,252 ----
  2322.   
  2323.       while (TRUE)
  2324.       {
  2325. !     Init_Input (TRUE);            /* Initialise        */
  2326.   
  2327.       while (((a_key = (char)getch ()) != 0x1a) && (a_key != NL) &&
  2328.           (a_key != '\r'))
  2329. ***************
  2330. *** 246,251 ****
  2331. --- 254,262 ----
  2332.   
  2333.   /* If function key, get the fkey value */
  2334.   
  2335. +             if ( a_key == 0xE0 )
  2336. +               a_key = 0;
  2337.           if (!a_key)
  2338.           f_key = (char)getch ();
  2339.   
  2340. ***************
  2341. *** 482,487 ****
  2342. --- 493,511 ----
  2343.   
  2344.              return TRUE;
  2345.   
  2346. +         case KF_JOBS:
  2347. +         v1_putc (NL);
  2348. +             dojobs(NULL);
  2349. +         put_prompt (last_prompt);
  2350. +         read_cursor_position ();
  2351. +             return TRUE;
  2352. +         case KF_CLS:
  2353. +             docls(NULL);
  2354. +         put_prompt (last_prompt);
  2355. +         read_cursor_position ();
  2356. +             return TRUE;
  2357.       case KF_DIRECTORY:        /* File name directory        */
  2358.           fn_search = TRUE;
  2359.   
  2360. ***************
  2361. *** 521,540 ****
  2362.   static void    set_cursor_shape (mode)
  2363.   bool        mode;
  2364.   {
  2365. !     union REGS        r;
  2366. ! /* Get the current cursor position to get the cursor lines */
  2367. !     r.h.ah = 0x03;
  2368. !     int86 (0x10, &r, &r);
  2369.   
  2370. ! /* Reset the type */
  2371.   
  2372. !     r.h.ah = 0x01;
  2373. !     r.h.ch = (unsigned char)(!mode ? r.h.cl - 1
  2374. !                    : (KF_List[KF_HALFHEIGTH].akey
  2375. !                     ? (r.h.cl / 2) + 1 : 1));
  2376. !     int86 (0x10, &r, &r);
  2377.   }
  2378.   #endif
  2379.   
  2380. --- 545,558 ----
  2381.   static void    set_cursor_shape (mode)
  2382.   bool        mode;
  2383.   {
  2384. !   VIOCURSORINFO vioci;
  2385.   
  2386. !   vioci.yStart = mode ? (KF_List[KF_HALFHEIGTH].akey ? -50 : 0) : -90;
  2387. !   vioci.cEnd = -100;
  2388. !   vioci.cx = 0;
  2389. !   vioci.attr = 0;
  2390.   
  2391. !   VioSetCurType(&vioci, 0);
  2392.   }
  2393.   #endif
  2394.   
  2395. ***************
  2396. *** 542,553 ****
  2397.   
  2398.   static void    read_cursor_position ()
  2399.   {
  2400. !     union REGS    r;
  2401.   
  2402. !     r.h.ah = 0x03;                /* Read cursor position    */
  2403. !     r.h.bh = 0;                    /* Page zero        */
  2404. !     int86 (0x10, &r, &r);
  2405. !     s_cursor = (r.h.dh * Max_Cols) + r.h.dl;
  2406.   }
  2407.   
  2408.   /* Re-position the cursor */
  2409. --- 560,569 ----
  2410.   
  2411.   static void    read_cursor_position ()
  2412.   {
  2413. !     USHORT usRow, usColumn;
  2414.   
  2415. !     VioGetCurPos(&usRow, &usColumn, 0);
  2416. !     s_cursor = (usRow * Max_Cols) + usColumn;
  2417.   }
  2418.   
  2419.   /* Re-position the cursor */
  2420. ***************
  2421. *** 557,579 ****
  2422.   int        new;
  2423.   {
  2424.       int diff;
  2425. !     union REGS    r;
  2426.   
  2427. !     r.h.ah = 0x02;                /* Set new position    */
  2428. !     r.h.bh = 0;                    /* Page zero        */
  2429. !     r.h.dh = (unsigned char)(new / Max_Cols);
  2430. !     r.h.dl = (unsigned char)(new % Max_Cols);
  2431.   
  2432.   /* Are we at the bottom of the page? */
  2433.   
  2434. !     if (r.h.dh >= (unsigned char)Max_Lines)
  2435.       {
  2436. !     diff = r.h.dh + 1 - Max_Lines;
  2437. !     r.h.dh = (unsigned char)(Max_Lines - 1);
  2438.       s_cursor -= Max_Cols * diff;
  2439.       }
  2440.   
  2441. !     int86 (0x10, &r, &r);
  2442.   }
  2443.   
  2444.   /* Erase to end of line (avoid need for STUPID ansi.sys memory eater!) */
  2445. --- 573,593 ----
  2446.   int        new;
  2447.   {
  2448.       int diff;
  2449. !     USHORT usRow, usColumn;
  2450.   
  2451. !     usRow    = (unsigned char)(new / Max_Cols);
  2452. !     usColumn = (unsigned char)(new % Max_Cols);
  2453.   
  2454.   /* Are we at the bottom of the page? */
  2455.   
  2456. !     if (usRow >= (unsigned char)Max_Lines)
  2457.       {
  2458. !     diff = usRow + 1 - Max_Lines;
  2459. !     usRow = (unsigned char)(Max_Lines - 1);
  2460.       s_cursor -= Max_Cols * diff;
  2461.       }
  2462.   
  2463. !     VioSetCurPos(usRow, usColumn, 0);
  2464.   }
  2465.   
  2466.   /* Erase to end of line (avoid need for STUPID ansi.sys memory eater!) */
  2467. ***************
  2468. *** 580,610 ****
  2469.   
  2470.   static void    erase_to_end_of_line ()
  2471.   {
  2472. !     union REGS        r;
  2473. !     unsigned char    backg;
  2474.   
  2475. ! /* Get the background attribute of the cursor */
  2476. !     r.h.ah = 0x08;
  2477. !     r.h.bh = 0;
  2478. !     int86 (0x10, &r, &r);
  2479. !     backg = r.h.ah & 0x07;
  2480. !     r.h.ah = 0x03;
  2481. !     r.h.bh = 0;
  2482. !     int86 (0x10, &r, &r);
  2483. ! /* Check that we use the correct m_line */
  2484. !     if (m_line < r.h.dh)
  2485. !     m_line = r.h.dh;
  2486. !     if ((r.x.cx = Max_Cols - r.h.dl + (m_line - r.h.dh) * Max_Cols) > 0)
  2487. !     {
  2488. !     r.x.ax = 0x0a20;
  2489. !     r.x.bx = backg;
  2490. !     int86 (0x10, &r, &r);
  2491. ! }
  2492.   }
  2493.   
  2494.   /* Generate the new cursor position */
  2495. --- 594,603 ----
  2496.   
  2497.   static void    erase_to_end_of_line ()
  2498.   {
  2499. !     USHORT usRow, usColumn;
  2500.   
  2501. !     VioGetCurPos(&usRow, &usColumn, 0);
  2502. !     VioWrtNChar(" ", Max_Cols - usColumn, usRow, usColumn, 0);
  2503.   }
  2504.   
  2505.   /* Generate the new cursor position */
  2506. ***************
  2507. *** 1069,1075 ****
  2508.       int            fn_len, pre_len, i;
  2509.       DIR            *dn;
  2510.       char        d_name [NAME_MAX + 1];
  2511. !     struct dirent    *d_ce;
  2512.       int            found_cnt = 0;
  2513.       int            max_per_line;
  2514.       static char        *ms_drive = "a:/";
  2515. --- 1062,1068 ----
  2516.       int            fn_len, pre_len, i;
  2517.       DIR            *dn;
  2518.       char        d_name [NAME_MAX + 1];
  2519. !     struct direct    *d_ce;
  2520.       int            found_cnt = 0;
  2521.       int            max_per_line;
  2522.       static char        *ms_drive = "a:/";
  2523. ***************
  2524. *** 1176,1182 ****
  2525.   
  2526.   /* Scan the directory */
  2527.   
  2528. !     while ((d_ce = readdir (dn)) != (struct dirent *)NULL)
  2529.       {
  2530.       if (strnicmp (d_ce->d_name, fn_mstart, fn_len) == 0)
  2531.       {
  2532. --- 1169,1175 ----
  2533.   
  2534.   /* Scan the directory */
  2535.   
  2536. !     while ((d_ce = readdir (dn)) != (struct direct *)NULL)
  2537.       {
  2538.       if (strnicmp (d_ce->d_name, fn_mstart, fn_len) == 0)
  2539.       {
  2540. ***************
  2541. *** 1269,1274 ****
  2542. --- 1262,1268 ----
  2543.       c_buffer_pos = l_buffer;    /* Initialise            */
  2544.       end_buffer = l_buffer;
  2545.       insert_mode = im;
  2546. +     set_cursor_shape (insert_mode);
  2547.       M_length = -1;
  2548.   
  2549.   /* Reset max line length and get the number of columns */
  2550. ***************
  2551. *** 1411,1426 ****
  2552.   
  2553.   void    In_Col_Zero ()
  2554.   {
  2555. !     union REGS        r;
  2556.   
  2557.       Get_Screen_Params ();
  2558.       read_cursor_position ();
  2559.   
  2560. !     r.h.ah = 0x08;
  2561. !     r.h.bh = 0x00;
  2562. !     int86 (0x10, &r, &r);
  2563.   
  2564. !     if ((s_cursor % Max_Cols) || (r.h.al != ' '))
  2565.       v1_putc (NL);
  2566.   }
  2567.   
  2568. --- 1405,1421 ----
  2569.   
  2570.   void    In_Col_Zero ()
  2571.   {
  2572. !     CHAR str[1];
  2573. !     USHORT cb = sizeof(str);
  2574. !     USHORT usRow, usColumn;
  2575.   
  2576.       Get_Screen_Params ();
  2577.       read_cursor_position ();
  2578.   
  2579. !     VioGetCurPos(&usRow, &usColumn, 0);
  2580. !     VioReadCharStr(str, &cb, usRow, usColumn, 0);
  2581.   
  2582. !     if ((s_cursor % Max_Cols) || (str[0] != ' '))
  2583.       v1_putc (NL);
  2584.   }
  2585.   
  2586. ***************
  2587. *** 1428,1453 ****
  2588.   
  2589.   static void    Get_Screen_Params ()
  2590.   {
  2591. !     union REGS        r;
  2592. !     Max_Cols = *(int *)(0x0040004aL);
  2593. !     Max_Lines = 25;
  2594. ! /* Is this an EGA?  This test was found in NANSI.SYS */
  2595.   
  2596. !     r.h.ah = 0x12;
  2597. !     r.x.bx = 0xff10;
  2598. !     int86 (0x10, &r, &r);
  2599.   
  2600. !     if (r.x.bx & 0xfefc)
  2601. !     return;
  2602.   
  2603. ! /* Else read the number of rows */
  2604.   
  2605. !     r.x.ax = 0x1130;
  2606. !     r.h.bh = 0;
  2607. !     int86 (0x10, &r, &r);
  2608. !     Max_Lines = r.h.dl + 1;
  2609.   }
  2610.   
  2611.   /* Ring Bell ? */
  2612. --- 1423,1448 ----
  2613.   
  2614.   static void    Get_Screen_Params ()
  2615.   {
  2616. !     VIOMODEINFO viomi;
  2617.   
  2618. !     viomi.cb = sizeof(viomi);
  2619. !     VioGetMode(&viomi, 0);
  2620.   
  2621. !     Max_Cols  = viomi.col;
  2622. !     Max_Lines = viomi.row;
  2623. ! }
  2624.   
  2625. ! /* Clear Screen */
  2626.   
  2627. ! int docls(C_Op *dummy)
  2628. ! {
  2629. !     v1_putc (27);
  2630. !     v1_putc ('[');
  2631. !     v1_putc ('2');
  2632. !     v1_putc ('J');
  2633. !     v1_putc (27);
  2634. !     v1_putc ('[');
  2635. !     v1_putc ('H');
  2636.   }
  2637.   
  2638.   /* Ring Bell ? */
  2639. diff -cbBwr orig/SRC/unistd.h os2/SRC/unistd.h
  2640. *** orig/SRC/unistd.h    Wed Feb 20 21:21:24 1991
  2641. --- os2/SRC/unistd.h    Mon May 21 20:26:10 1990
  2642. ***************
  2643. *** 4,10 ****
  2644.   /*  unistd.h  */
  2645.   
  2646.   #include <sys/types.h>
  2647. ! #include <sys/proto.h>
  2648.   
  2649.   /* Definition for NULL pointer */
  2650.   
  2651. --- 4,11 ----
  2652.   /*  unistd.h  */
  2653.   
  2654.   #include <sys/types.h>
  2655. ! #include <proto.h>
  2656. ! #include <changes.h>
  2657.   
  2658.   /* Definition for NULL pointer */
  2659.   
  2660.