home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK6 / OS_15 / SH.ZIP / PATCHES.OS2 < prev    next >
Text File  |  1994-01-24  |  70KB  |  2,909 lines

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