home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / ms_sh16.lzh / ms_sh.6 < prev    next >
Text File  |  1990-05-06  |  39KB  |  1,726 lines

  1.  
  2. #!/bin/sh
  3. # this is part 6 of a multipart archive
  4. # do not concatenate these parts, unpack them in order with /bin/sh
  5. # file Patch1.6 continued
  6. #
  7. CurArch=6
  8. if test ! -r s2_seq_.tmp
  9. then echo "Please unpack part 1 first!"
  10.      exit 1; fi
  11. ( read Scheck
  12.   if test "$Scheck" != $CurArch
  13.   then echo "Please unpack part $Scheck next!"
  14.        exit 1;
  15.   else exit 0; fi
  16. ) < s2_seq_.tmp || exit 1
  17. echo "x - Continuing file Patch1.6"
  18. sed 's/^X//' << 'SHAR_EOF' >> Patch1.6
  19. X!  */
  20. X  
  21. X+     if (strnicmp (name, "/dev/", 5) == 0)
  22. X+     {
  23. X+     if (stricmp (&name[5], "tty") == 0)
  24. X+         strcpy (&name[5], "con");
  25. X+ 
  26. X+     else if (stricmp (&name[5], "null") == 0)
  27. X+         strcpy (&name[5], "nul");
  28. X+ 
  29. X+     mode &= ~(O_CREAT | O_TRUNC);
  30. X+     }
  31. X+ 
  32. X      fp->fl_name  = strcpy (f_name, name);
  33. X      fp->fl_close = d_flag;
  34. X      fp->fl_size  = F_START;
  35. X***************
  36. X*** 260,266 ****
  37. X   * Add the ID to the ID array for this file
  38. X   */
  39. X  
  40. X! void    S_Remap (old_fid, new_fid)
  41. X  int    old_fid, new_fid;
  42. X  {
  43. X      s_flist    *fp = find_entry (old_fid);
  44. X--- 297,303 ----
  45. X   * Add the ID to the ID array for this file
  46. X   */
  47. X  
  48. X! int    S_Remap (old_fid, new_fid)
  49. X  int    old_fid, new_fid;
  50. X  {
  51. X      s_flist    *fp = find_entry (old_fid);
  52. X***************
  53. X*** 268,284 ****
  54. X      int        i;
  55. X  
  56. X      if (fp == (s_flist *)NULL)
  57. X!     return;
  58. X  
  59. X  /* Is there an empty slot ? */
  60. X  
  61. X      for (i = 0; i < fp->fl_count; i++)
  62. X      {
  63. X      if (fp->fl_fd[i] == -1)
  64. X!     {
  65. X!         fp->fl_fd[i] = new_fid;
  66. X!         return;
  67. X!     }
  68. X      }
  69. X  
  70. X  /* Is there any room at the end ? No - grap somemore space and effect a
  71. X--- 305,318 ----
  72. X      int        i;
  73. X  
  74. X      if (fp == (s_flist *)NULL)
  75. X!     return new_fid;
  76. X  
  77. X  /* Is there an empty slot ? */
  78. X  
  79. X      for (i = 0; i < fp->fl_count; i++)
  80. X      {
  81. X      if (fp->fl_fd[i] == -1)
  82. X!         return (fp->fl_fd[i] = new_fid);
  83. X      }
  84. X  
  85. X  /* Is there any room at the end ? No - grap somemore space and effect a
  86. X***************
  87. X*** 290,296 ****
  88. X      {
  89. X      if ((flist = (int *) space ((fp->fl_size + F_START) * sizeof (int)))
  90. X          == (int *)NULL)
  91. X!         return;
  92. X  
  93. X      memcpy ((char *)flist, (char *)fp->fl_fd, sizeof (int) * fp->fl_size);
  94. X      DELETE (fp->fl_fd);
  95. X--- 324,330 ----
  96. X      {
  97. X      if ((flist = (int *) space ((fp->fl_size + F_START) * sizeof (int)))
  98. X          == (int *)NULL)
  99. X!         return new_fid;
  100. X  
  101. X      memcpy ((char *)flist, (char *)fp->fl_fd, sizeof (int) * fp->fl_size);
  102. X      DELETE (fp->fl_fd);
  103. X***************
  104. X*** 299,305 ****
  105. X      fp->fl_size += F_START;
  106. X      }
  107. X  
  108. X!     fp->fl_fd[fp->fl_count++] = new_fid;
  109. X  }
  110. X  
  111. X  /*
  112. X--- 333,339 ----
  113. X      fp->fl_size += F_START;
  114. X      }
  115. X  
  116. X!     return (fp->fl_fd[fp->fl_count++] = new_fid);
  117. X  }
  118. X  
  119. X  /*
  120. X***************
  121. X*** 323,329 ****
  122. X  int    old_fid;
  123. X  int    new_fid;
  124. X  {
  125. X!     int        res = 0;
  126. X      int        i;
  127. X      Save_IO    *sp;
  128. X  
  129. X--- 357,363 ----
  130. X  int    old_fid;
  131. X  int    new_fid;
  132. X  {
  133. X!     int        res = -1;
  134. X      int        i;
  135. X      Save_IO    *sp;
  136. X  
  137. X***************
  138. X*** 391,408 ****
  139. X      if ((old_fid != -1) && ((res = dup2 (old_fid, new_fid)) >= 0))
  140. X      {
  141. X      S_close (new_fid, FALSE);
  142. X!     S_Remap (old_fid, new_fid);
  143. X      }
  144. X  
  145. X      return res;
  146. X  }
  147. X  
  148. X  /*
  149. X!  * Restore the Stdin, Stdout and Stderr to original values
  150. X   */
  151. X  
  152. X! int    restore_std (rv)
  153. X  int    rv;
  154. X  {
  155. X      int        j, i;
  156. X      Save_IO    *sp;
  157. X--- 425,444 ----
  158. X      if ((old_fid != -1) && ((res = dup2 (old_fid, new_fid)) >= 0))
  159. X      {
  160. X      S_close (new_fid, FALSE);
  161. X!     res = S_Remap (old_fid, new_fid);
  162. X      }
  163. X  
  164. X      return res;
  165. X  }
  166. X  
  167. X  /*
  168. X!  * Restore the Stdin, Stdout and Stderr to original values.  If change is
  169. X!  * FALSE, just remove entries from stack.  A special case for exec.
  170. X   */
  171. X  
  172. X! int    restore_std (rv, change)
  173. X  int    rv;
  174. X+ bool    change;
  175. X  {
  176. X      int        j, i;
  177. X      Save_IO    *sp;
  178. X***************
  179. X*** 422,429 ****
  180. X  
  181. X      --NSave_IO_E;
  182. X  
  183. X! /* Close and restore any files */
  184. X  
  185. X      for (i = STDIN_FILENO; i <= STDERR_FILENO; i++)
  186. X      {
  187. X          if (sp->fp[i] != -1)
  188. X--- 458,470 ----
  189. X  
  190. X      --NSave_IO_E;
  191. X  
  192. X! /* If special case (changed at this level) - continue */
  193. X  
  194. X+     if (!change && (sp->depth == Execute_stack_depth))
  195. X+         continue;
  196. X+ 
  197. X+ /* Close and restore any files */
  198. X+ 
  199. X      for (i = STDIN_FILENO; i <= STDERR_FILENO; i++)
  200. X      {
  201. X          if (sp->fp[i] != -1)
  202. X***************
  203. X*** 504,553 ****
  204. X   * handler for the file
  205. X   */
  206. X  
  207. X! int    O_for_execute (path)
  208. X  char    *path;
  209. X  {
  210. X!     int        i, end;
  211. X!     char    local_path[FFNAME_MAX];
  212. X  
  213. X  /* Work on a copy of the path */
  214. X  
  215. X!     strcpy (local_path, path);
  216. X  
  217. X  /* Try the file name and then with a .sh appended */
  218. X  
  219. X!     for (end = 0; end < 2; end++)
  220. X!     {
  221. X!     if ((i = Check_Script (local_path)) >= 0)
  222. X!         return i;
  223. X  
  224. X!     if (!end)
  225. X!         strcat (local_path, ".sh");
  226. X!     }
  227. X! 
  228. X!     return -1;
  229. X  }
  230. X  
  231. X  /*
  232. X   * Check for shell script
  233. X   */
  234. X  
  235. X! int    Check_Script (path)
  236. X  char    *path;
  237. X  {
  238. X!     char    buf[5];
  239. X!     int        i;
  240. X  
  241. X!     if (((i = S_open (FALSE, path, O_RMASK)) >= 0) &&
  242. X!     ((read (i, buf, 6) == 5) && (strncmp (buf, "#!sh\n", 5) == 0)))
  243. X!     return i;
  244. X  
  245. X!     if (i != -1)
  246. X!     S_close (i, TRUE);
  247. X  
  248. X!     return -1;
  249. X! }
  250. X  
  251. X  /*
  252. X   * Convert slashes to backslashes for MSDOS
  253. X   */
  254. X--- 545,677 ----
  255. X   * handler for the file
  256. X   */
  257. X  
  258. X! int    O_for_execute (path, params, nargs)
  259. X  char    *path;
  260. X+ char    **params;
  261. X+ int    *nargs;
  262. X  {
  263. X!     int        i = -1;
  264. X!     char    *local_path;
  265. X  
  266. X  /* Work on a copy of the path */
  267. X  
  268. X!     if ((local_path = getcell (strlen (path) + 4)) == (char *)NULL)
  269. X!     return -1;
  270. X  
  271. X  /* Try the file name and then with a .sh appended */
  272. X  
  273. X!     if ((i = Check_Script (strcpy (local_path, path), params, nargs)) < 0)
  274. X!     i = Check_Script (strcat (local_path, ".sh"), params, nargs);
  275. X  
  276. X!     DELETE (local_path);
  277. X!     return i;
  278. X  }
  279. X  
  280. X  /*
  281. X   * Check for shell script
  282. X   */
  283. X  
  284. X! int    Check_Script (path, params, nargs)
  285. X  char    *path;
  286. X+ char    **params;
  287. X+ int    *nargs;
  288. X  {
  289. X!     char    buf[512];        /* Input buffer            */
  290. X!     int        fp;            /* File handler            */
  291. X!     int        nbytes;            /* Number of bytes read        */
  292. X!     char    *bp;            /* Pointers into buffers    */
  293. X!     char    *ep;
  294. X  
  295. X!     if ((fp = S_open (FALSE, path, O_RMASK)) < 0)
  296. X!     return -1;
  297. X  
  298. X! /* zero or less bytes - not a script */
  299. X  
  300. X!     memset (buf, 0, 512);
  301. X!     nbytes = read (fp, buf, 512);
  302. X  
  303. X+     for (ep = &buf[nbytes], bp = buf; (bp < ep) && ((unsigned char)*bp >= 0x08); ++bp);
  304. X+ 
  305. X+ /* If non-ascii file or lenght is less than 1 - not a script */
  306. X+ 
  307. X+     if ((bp != ep) || (nbytes < 1))
  308. X+     {
  309. X+     S_close (fp, TRUE);
  310. X+     return -1;
  311. X+     }
  312. X+ 
  313. X+ /* Ensure end of buffer detected */
  314. X+ 
  315. X+     buf[511] = 0;
  316. X+ 
  317. X+ /* Initialise the return parameters, if specified */
  318. X+ 
  319. X+     if (params != (char **)NULL)
  320. X+     *params = null;
  321. X+ 
  322. X+     if (nargs != (int *)NULL)
  323. X+     *nargs = 0;
  324. X+ 
  325. X+ /* We don't care how many bytes were read now, so use it to count the
  326. X+  * additional arguments
  327. X+  */
  328. X+ 
  329. X+     nbytes = 0;
  330. X+ 
  331. X+ /* Find the end of the first line */
  332. X+ 
  333. X+     if ((bp = strchr (buf, '\n')) != (char *)NULL)
  334. X+     *bp = 0;
  335. X+     
  336. X+     bp = buf;
  337. X+     ep = (char *)NULL;
  338. X+ 
  339. X+ /* Check for script */
  340. X+ 
  341. X+     if ((*(bp++) != '#') || (*(bp++) != '!'))
  342. X+     return fp;
  343. X+ 
  344. X+     while (*bp)
  345. X+     {
  346. X+     while (isspace (*bp))
  347. X+         ++bp;
  348. X+ 
  349. X+ /* Save the start of the arguments */
  350. X+ 
  351. X+     if (*bp)
  352. X+     {
  353. X+         if (ep == (char *)NULL)
  354. X+         ep = bp;
  355. X+ 
  356. X+ /* Count the arguments */
  357. X+ 
  358. X+         ++nbytes;
  359. X+     }
  360. X+ 
  361. X+     while (!isspace (*bp) && *bp)
  362. X+         ++bp;
  363. X+     }
  364. X+ 
  365. X+ /* Set up the return parameters, if appropriate */
  366. X+ 
  367. X+     if ((params != (char **)NULL) && (strlen (ep) != 0))
  368. X+     {
  369. X+     if ((*params = getcell (strlen (ep) + 1)) == (char *)NULL)
  370. X+     {
  371. X+         *params = null;
  372. X+         S_close (fp, TRUE);
  373. X+         return -1;
  374. X+     }
  375. X+ 
  376. X+     strcpy (*params, ep);
  377. X+     }
  378. X+ 
  379. X+     if (nargs != (int *)NULL)
  380. X+     *nargs = nbytes;
  381. X+ 
  382. X+     return fp;
  383. X+ }
  384. X+ 
  385. X  /*
  386. X   * Convert slashes to backslashes for MSDOS
  387. X   */
  388. X***************
  389. X*** 561,565 ****
  390. X--- 685,767 ----
  391. X          *sp = '\\';
  392. X  
  393. X      ++sp;
  394. X+     }
  395. X+ }
  396. X+ 
  397. X+ /*
  398. X+  * Some buffered Output functions to speed somethings up.
  399. X+  */
  400. X+ 
  401. X+ /* Open the buffer */
  402. X+ 
  403. X+ Out_Buf    *Open_buffer (fid, f_abort)
  404. X+ int    fid;
  405. X+ bool    f_abort;
  406. X+ {
  407. X+     Out_Buf    *bp;
  408. X+ 
  409. X+     if (((bp = (Out_Buf *)getcell (sizeof (Out_Buf))) == (Out_Buf *)NULL) ||
  410. X+     ((bp->ob_start = getcell (BIO_LENGTH)) == (char *)NULL))
  411. X+     {
  412. X+     if (f_abort)
  413. X+     {
  414. X+         print_error ("sh: %s\n", strerror (ENOMEM));
  415. X+         fail ();
  416. X+     }
  417. X+ 
  418. X+     return (Out_Buf *)NULL;
  419. X+     }
  420. X+ 
  421. X+ /* Ok - save info */
  422. X+ 
  423. X+     bp->ob_fid = fid;
  424. X+     bp->ob_cur = bp->ob_start;
  425. X+     return bp;
  426. X+ }
  427. X+ 
  428. X+ /* Add a character to the buffer */
  429. X+ 
  430. X+ void        Add_buffer (c, bp)
  431. X+ char        c;
  432. X+ Out_Buf        *bp;
  433. X+ {
  434. X+     *(bp->ob_cur++) = c;
  435. X+ 
  436. X+     if (bp->ob_cur == &bp->ob_start[BIO_LENGTH - 1])
  437. X+     {
  438. X+     write (bp->ob_fid, bp->ob_start, BIO_LENGTH - 1);
  439. X+     bp->ob_cur = bp->ob_start;
  440. X+     }
  441. X+ }
  442. X+ 
  443. X+ /* Close the buffer */
  444. X+ 
  445. X+ void        Close_buffer (bp)
  446. X+ Out_Buf        *bp;
  447. X+ {
  448. X+     int        n;
  449. X+ 
  450. X+     if ((n = (int)(bp->ob_cur - bp->ob_start)))
  451. X+     write (bp->ob_fid, bp->ob_start, n);
  452. X+     
  453. X+     DELETE (bp->ob_start);
  454. X+     DELETE (bp);
  455. X+ }
  456. X+ 
  457. X+ /* Output string */
  458. X+ 
  459. X+ void        Adds_buffer (s, bp)
  460. X+ char        *s;
  461. X+ Out_Buf        *bp;
  462. X+ {
  463. X+     while (*s)
  464. X+     {
  465. X+     *(bp->ob_cur++) = *(s++);
  466. X+ 
  467. X+     if (bp->ob_cur == &bp->ob_start[BIO_LENGTH - 1])
  468. X+     {
  469. X+         write (bp->ob_fid, bp->ob_start, BIO_LENGTH - 1);
  470. X+         bp->ob_cur = bp->ob_start;
  471. X+     }
  472. X      }
  473. X  }
  474. XIndex: shell/sh1.c
  475. XPrereq: 1.2
  476. X*** ../sh15/shell/sh1.c    Fri Feb 16 19:12:27 1990
  477. X--- shell/sh1.c    Tue May  1 19:48:00 1990
  478. X***************
  479. X*** 13,21 ****
  480. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  481. X   *     (or parts of sources) cannot be sold under any circumstances.
  482. X   *
  483. X!  *    $Header: sh1.c 1.2 90/02/14 04:46:20 MS_user Exp $
  484. X   *
  485. X   *    $Log:    sh1.c $
  486. X   * Revision 1.2  90/02/14  04:46:20  MS_user
  487. X   * Add Interrupt 24 processing
  488. X   * 
  489. X--- 13,60 ----
  490. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  491. X   *     (or parts of sources) cannot be sold under any circumstances.
  492. X   *
  493. X!  *    $Header: sh1.c 1.14 90/04/25 22:33:28 MS_user Exp $
  494. X   *
  495. X   *    $Log:    sh1.c $
  496. X+  * Revision 1.14  90/04/25  22:33:28  MS_user
  497. X+  * Fix rsh check for PATH
  498. X+  * 
  499. X+  * Revision 1.13  90/04/25  09:18:12  MS_user
  500. X+  * Change version message processing
  501. X+  * 
  502. X+  * Revision 1.12  90/04/04  11:32:12  MS_user
  503. X+  * Change MAILPATH to use a semi-colon and not a colon for DOS
  504. X+  * 
  505. X+  * Revision 1.11  90/04/03  17:58:35  MS_user
  506. X+  * Stop shell exit from lowest level CLI
  507. X+  * 
  508. X+  * Revision 1.10  90/03/27  20:24:49  MS_user
  509. X+  * Fix problem with Interrupts not restoring std??? and clearing extended file
  510. X+  * 
  511. X+  * Revision 1.9  90/03/26  20:56:13  MS_user
  512. X+  * Change I/O restore so that "exec >filename" works
  513. X+  * 
  514. X+  * Revision 1.8  90/03/26  04:30:14  MS_user
  515. X+  * Remove original Interrupt 24 save address
  516. X+  * 
  517. X+  * Revision 1.7  90/03/12  20:16:22  MS_user
  518. X+  * Save program name for Initialisation file processing
  519. X+  * 
  520. X+  * Revision 1.6  90/03/09  16:05:33  MS_user
  521. X+  * Add build file name function and change the profile check to use it
  522. X+  * 
  523. X+  * Revision 1.5  90/03/06  16:49:14  MS_user
  524. X+  * Add disable history option
  525. X+  * 
  526. X+  * Revision 1.4  90/03/06  15:09:27  MS_user
  527. X+  * Add Unix PATH variable conversion
  528. X+  * 
  529. X+  * Revision 1.3  90/03/05  13:47:45  MS_user
  530. X+  * Get /etc/profile and profile order rigth
  531. X+  * Use $HOME/profile and not profile
  532. X+  * Check cursor position before outputing prompt
  533. X+  * Move some of processing in main to sub-routines
  534. X+  * 
  535. X   * Revision 1.2  90/02/14  04:46:20  MS_user
  536. X   * Add Interrupt 24 processing
  537. X   * 
  538. X***************
  539. X*** 61,68 ****
  540. X  static char    *search    = ";c:/bin;c:/usr/bin";
  541. X  static char    *ymail     = "You have mail\n";
  542. X  static char    *Path       = "PATH";
  543. X  #ifdef SIGQUIT
  544. X! static void    (*qflag)() = SIG_IGN;
  545. X  #endif
  546. X  
  547. X  /* Functions */
  548. X--- 100,109 ----
  549. X  static char    *search    = ";c:/bin;c:/usr/bin";
  550. X  static char    *ymail     = "You have mail\n";
  551. X  static char    *Path       = "PATH";
  552. X+                     /* Original Interrupt 24 address */
  553. X+ static void    (interrupt far *Orig_I24_V) (void);
  554. X  #ifdef SIGQUIT
  555. X! static void    (*qflag)(int) = SIG_IGN;
  556. X  #endif
  557. X  
  558. X  /* Functions */
  559. X***************
  560. X*** 70,80 ****
  561. X  static char    *cclass (char *, int, bool);
  562. X  static char    *copy_to_equals (char *, char *);
  563. X  static void    nameval (Var_List *, char *, char *, bool);
  564. X! static void    patch_up (void);
  565. X  static void    onecommand (void);
  566. X  static void    Check_Mail (void);
  567. X  static void    Pre_Process_Argv (char **);
  568. X  static void    Load_G_VL (void);
  569. X  
  570. X  /*
  571. X   * The main program starts here
  572. X--- 111,124 ----
  573. X  static char    *cclass (char *, int, bool);
  574. X  static char    *copy_to_equals (char *, char *);
  575. X  static void    nameval (Var_List *, char *, char *, bool);
  576. X! static bool    Initialise (char *);
  577. X  static void    onecommand (void);
  578. X  static void    Check_Mail (void);
  579. X  static void    Pre_Process_Argv (char **);
  580. X  static void    Load_G_VL (void);
  581. X+ static void    Convert_Backslashes (char *);
  582. X+ static void    Load_profiles (void);
  583. X+ static void    U2D_Path (void);
  584. X  
  585. X  /*
  586. X   * The main program starts here
  587. X***************
  588. X*** 85,183 ****
  589. X  register char    **argv;
  590. X  {
  591. X      register int    f;
  592. X-     register char    *s, *s1;
  593. X      int            cflag = 0;
  594. X      int            sc;
  595. X!     char        *name, **ap;
  596. X      int            (*iof)(IO_State *) = filechar;
  597. X!     Var_List        *lset;
  598. X!     bool        l_rflag = FALSE;
  599. X  
  600. X- /* Patch up various parts of the system */
  601. X- 
  602. X-     patch_up ();
  603. X- 
  604. X- /* Load the environment into our structures */
  605. X- 
  606. X-     if ((ap = environ) != (char **)NULL)
  607. X-     {
  608. X-     while (*ap)
  609. X-         assign (*ap++, !COPYV);
  610. X- 
  611. X-     for (ap = environ; *ap;)
  612. X-         s_vstatus (lookup (*ap++, TRUE), EXPORT);
  613. X-     }
  614. X- 
  615. X- /* Zap all files */
  616. X- 
  617. X-     closeall ();
  618. X-     areanum = 1;
  619. X- 
  620. X- /* Get the current directory */
  621. X- 
  622. X-     Getcwd ();
  623. X- 
  624. X- /* Set up some stardard variables if their not set */
  625. X- 
  626. X-     if ((lset = lookup (shell, TRUE))->value == null)
  627. X-     setval (lset, shellname);
  628. X- 
  629. X-     s_vstatus (lset, EXPORT);
  630. X- 
  631. X- /* Check for restricted shell */
  632. X- 
  633. X-     if ((s = strrchr (lset->value, '/')) == (char *)NULL)
  634. X-     s = lset->value;
  635. X- 
  636. X-     else
  637. X-     s++;
  638. X- 
  639. X-     if (*s == 'r')
  640. X-     l_rflag = TRUE;
  641. X- 
  642. X- /* Set up home directory */
  643. X- 
  644. X-     if ((lset = lookup (home, TRUE))->value == null)
  645. X-     setval (lset, "c:/");
  646. X- 
  647. X-     s_vstatus (lset, EXPORT);
  648. X- 
  649. X- /* Set up history file location */
  650. X- 
  651. X-     setval (lookup ("$", TRUE), putn (getpid ()));
  652. X- 
  653. X-     Load_G_VL ();
  654. X-     path->status |= (EXPORT | PONLY);
  655. X-     ifs->status  |= (EXPORT | PONLY);
  656. X-     ps1->status  |= (EXPORT | PONLY);
  657. X-     ps2->status  |= (EXPORT | PONLY);
  658. X- 
  659. X-     if (path->value == null)
  660. X-     setval (path, search);
  661. X- 
  662. X-     if (ifs->value == null)
  663. X-     setval (ifs, " \t\n");
  664. X- 
  665. X-     if (ps1->value == null)
  666. X-     setval (ps1, "$ ");
  667. X- 
  668. X-     if (ps2->value == null)
  669. X-     setval (ps2, "> ");
  670. X- 
  671. X- /* Check the restricted shell */
  672. X- 
  673. X-     if ((s = strrchr ((name = *argv), '/')) == (char *)NULL)
  674. X-     s = name;
  675. X- 
  676. X-     if ((s1 = strchr (s, '.')) != (char *)NULL)
  677. X-     *s1 = 0;
  678. X- 
  679. X-     if (strcmp (s, "rsh") == 0)
  680. X-     l_rflag = TRUE;
  681. X- 
  682. X-     if (s1 != (char *)NULL)
  683. X-     *s1 = '.';
  684. X- 
  685. X  /* Preprocess options to convert two character options of the form /x to
  686. X   * -x.  Some programs!!
  687. X   */
  688. X--- 129,143 ----
  689. X  register char    **argv;
  690. X  {
  691. X      register int    f;
  692. X      int            cflag = 0;
  693. X      int            sc;
  694. X!     char        *name = *argv;
  695. X!     char        **ap;
  696. X      int            (*iof)(IO_State *) = filechar;
  697. X!                     /* Load up various parts of the    */
  698. X!                     /* system            */
  699. X!     bool        l_rflag = Initialise (*argv);
  700. X  
  701. X  /* Preprocess options to convert two character options of the form /x to
  702. X   * -x.  Some programs!!
  703. X   */
  704. X***************
  705. X*** 224,230 ****
  706. X          break;
  707. X  
  708. X          case 'i':                /* Set interactive    */
  709. X!         talking++;
  710. X  
  711. X          default:
  712. X          if (islower (sc))
  713. X--- 184,190 ----
  714. X          break;
  715. X  
  716. X          case 'i':                /* Set interactive    */
  717. X!         talking = TRUE;
  718. X  
  719. X          default:
  720. X          if (islower (sc))
  721. X***************
  722. X*** 250,263 ****
  723. X  
  724. X      if (strcmp ((name = *argv), "-") != 0)
  725. X      {
  726. X!         if ((f = O_for_execute (name)) < 0)
  727. X          {
  728. X          print_error ("%s: cannot open\n", name);
  729. X          exit (1);
  730. X          }
  731. X      }
  732. X  
  733. X!     next (remap (f));        /* Load into I/O stack    */
  734. X      }
  735. X  
  736. X  /* Set up the $- variable */
  737. X--- 210,223 ----
  738. X  
  739. X      if (strcmp ((name = *argv), "-") != 0)
  740. X      {
  741. X!         if ((f = O_for_execute (name, (char **)NULL, (int *)NULL)) < 0)
  742. X          {
  743. X          print_error ("%s: cannot open\n", name);
  744. X          exit (1);
  745. X          }
  746. X      }
  747. X  
  748. X!     PUSHIO (afile, remap (f), filechar);     /* Load into I/O stack    */
  749. X      }
  750. X  
  751. X  /* Set up the $- variable */
  752. X***************
  753. X*** 272,283 ****
  754. X  
  755. X      if (isatty (0) && isatty (1) && !cflag)
  756. X      {
  757. X!         fprintf (stderr, Copy_Right1, _osmajor, _osminor);
  758. X!         fputs (Copy_Right2, stderr);
  759. X  
  760. X!         talking++;
  761. X          History_Enabled = TRUE;
  762. X          Load_History ();
  763. X      }
  764. X      }
  765. X  
  766. X--- 232,245 ----
  767. X  
  768. X      if (isatty (0) && isatty (1) && !cflag)
  769. X      {
  770. X!         Print_Version (2);
  771. X  
  772. X!         talking = TRUE;
  773. X! #ifndef NO_HISTORY
  774. X          History_Enabled = TRUE;
  775. X          Load_History ();
  776. X+         Configure_Keys ();
  777. X+ #endif
  778. X      }
  779. X      }
  780. X  
  781. X***************
  782. X*** 288,303 ****
  783. X  /* Read profile ? */
  784. X  
  785. X      if (((name != (char *)NULL) && (*name == '-')) || level0)
  786. X!     {
  787. X!     talking++;
  788. X  
  789. X-     if ((f = O_for_execute ("/etc/profile")) >= 0)
  790. X-         next (remap(f));
  791. X- 
  792. X-     if ((f = O_for_execute ("profile")) >= 0)
  793. X-         next (remap(f));
  794. X-     }
  795. X- 
  796. X  /* Set up signals */
  797. X  
  798. X      if (talking)
  799. X--- 250,257 ----
  800. X  /* Read profile ? */
  801. X  
  802. X      if (((name != (char *)NULL) && (*name == '-')) || level0)
  803. X!     Load_profiles ();
  804. X  
  805. X  /* Set up signals */
  806. X  
  807. X      if (talking)
  808. X***************
  809. X*** 332,340 ****
  810. X--- 286,296 ----
  811. X      {
  812. X      if (talking && e.iop <= iostack)
  813. X      {
  814. X+         In_Col_Zero ();
  815. X          Check_Mail ();
  816. X          put_prompt (ps1->value);
  817. X          r_flag = l_rflag;
  818. X+         closeall ();        /* Clean up any open shell files */
  819. X      }
  820. X  
  821. X      onecommand ();
  822. X***************
  823. X*** 366,374 ****
  824. X  {
  825. X      register int    i;
  826. X      jmp_buf        m1;
  827. X!     C_Op        *outtree;
  828. X  
  829. X- 
  830. X  /* Exit any previous environments */
  831. X  
  832. X      while (e.oenv)
  833. X--- 322,329 ----
  834. X  {
  835. X      register int    i;
  836. X      jmp_buf        m1;
  837. X!     C_Op        *outtree = (C_Op *)NULL;
  838. X  
  839. X  /* Exit any previous environments */
  840. X  
  841. X      while (e.oenv)
  842. X***************
  843. X*** 397,404 ****
  844. X      SW_intr)
  845. X      {
  846. X  
  847. X! /* Failed - clean up */
  848. X  
  849. X      while (e.oenv)
  850. X          quitenv ();
  851. X  
  852. X--- 352,371 ----
  853. X      SW_intr)
  854. X      {
  855. X  
  856. X! /* Failed - If parse failed - save command line as history */
  857. X  
  858. X+ #ifndef NO_HISTORY
  859. X+     if ((outtree == (C_Op *)NULL) && Interactive ())
  860. X+         Add_History (FALSE);
  861. X+ #endif
  862. X+ 
  863. X+ /* If interrupt occured, remove current Input stream */
  864. X+ 
  865. X+     if (SW_intr && (e.iop > e.iobase))
  866. X+         e.iop--;
  867. X+ 
  868. X+ /* Quit all environments */
  869. X+ 
  870. X      while (e.oenv)
  871. X          quitenv ();
  872. X  
  873. X***************
  874. X*** 436,456 ****
  875. X  
  876. X  /* Save the environment information */
  877. X  
  878. X!     if (talking && e.iop <= iostack)
  879. X      Add_History (FALSE);
  880. X  
  881. X!     if (!FL_TEST ('n'))
  882. X!     execute (outtree, NOPIPE, NOPIPE, 0);
  883. X  
  884. X  /* Make sure the I/O and environment are back at level 0 and then clear them */
  885. X  
  886. X      Execute_stack_depth = 0;
  887. X  
  888. X      if (NSubShells != 0)
  889. X      Delete_G_VL ();
  890. X  
  891. X      if (NSave_IO_E)
  892. X!     restore_std (0);
  893. X  
  894. X      if (MSubShells)
  895. X      DELETE (SubShells);
  896. X--- 403,428 ----
  897. X  
  898. X  /* Save the environment information */
  899. X  
  900. X! #ifndef NO_HISTORY
  901. X!     if (Interactive ())
  902. X      Add_History (FALSE);
  903. X+ #endif
  904. X  
  905. X! /* Ok - if we wail, we need to clean up the stacks */
  906. X  
  907. X+     if ((setjmp (failpt = m1) == 0) && !FL_TEST ('n'))
  908. X+     execute (outtree, NOPIPE, NOPIPE, 0);
  909. X+ 
  910. X  /* Make sure the I/O and environment are back at level 0 and then clear them */
  911. X  
  912. X      Execute_stack_depth = 0;
  913. X+     Clear_Extended_File ();
  914. X  
  915. X      if (NSubShells != 0)
  916. X      Delete_G_VL ();
  917. X  
  918. X      if (NSave_IO_E)
  919. X!     restore_std (0, TRUE);
  920. X  
  921. X      if (MSubShells)
  922. X      DELETE (SubShells);
  923. X***************
  924. X*** 495,502 ****
  925. X      if (execflg)
  926. X      fail ();
  927. X  
  928. X! /* Clean up */
  929. X  
  930. X      scraphere ();
  931. X      freehere (1);
  932. X  
  933. X--- 467,480 ----
  934. X      if (execflg)
  935. X      fail ();
  936. X  
  937. X!     if (Orig_I24_V == (void (far *)())NULL)
  938. X!     {
  939. X!     S_puts ("sh: ignoring attempt to leave lowest level shell\n");
  940. X!     fail ();
  941. X!     }
  942. X  
  943. X+ /* Clean up */
  944. X+ 
  945. X      scraphere ();
  946. X      freehere (1);
  947. X  
  948. X***************
  949. X*** 506,513 ****
  950. X--- 484,493 ----
  951. X  
  952. X  /* Dump history on exit */
  953. X  
  954. X+ #ifndef NO_HISTORY
  955. X      if (talking && isatty(0))
  956. X      Dump_History ();
  957. X+ #endif
  958. X  
  959. X      closeall ();
  960. X      exit (exstat);
  961. X***************
  962. X*** 608,614 ****
  963. X      }
  964. X  
  965. X      *ep = e;
  966. X!     e.oenv = ep;
  967. X      e.errpt = errpt;
  968. X      return FALSE;
  969. X  }
  970. X--- 588,595 ----
  971. X      }
  972. X  
  973. X      *ep = e;
  974. X!     e.eof_p = FALSE;            /* Disable EOF processing    */
  975. X!     e.oenv  = ep;
  976. X      e.errpt = errpt;
  977. X      return FALSE;
  978. X  }
  979. X***************
  980. X*** 669,684 ****
  981. X  }
  982. X  
  983. X  /*
  984. X-  * Add a file to the input stack
  985. X-  */
  986. X- 
  987. X- void    next (f)
  988. X- int    f;
  989. X- {
  990. X-     PUSHIO (afile, f, filechar);
  991. X- }
  992. X- 
  993. X- /*
  994. X   * SIGINT interrupt processing
  995. X   */
  996. X  
  997. X--- 650,655 ----
  998. X***************
  999. X*** 696,707 ****
  1000. X      if (talking)
  1001. X      {
  1002. X      if (inparse)
  1003. X-     {
  1004. X          S_putc (NL);
  1005. X-         fail ();
  1006. X-     }
  1007. X-     }
  1008. X  
  1009. X  /* No - exit */
  1010. X  
  1011. X      else
  1012. X--- 667,679 ----
  1013. X      if (talking)
  1014. X      {
  1015. X      if (inparse)
  1016. X          S_putc (NL);
  1017. X  
  1018. X+ /* Abandon processing */
  1019. X+ 
  1020. X+     fail ();
  1021. X+     }
  1022. X+ 
  1023. X  /* No - exit */
  1024. X  
  1025. X      else
  1026. X***************
  1027. X*** 751,756 ****
  1028. X--- 723,731 ----
  1029. X  void        sig (i)
  1030. X  register int    i;
  1031. X  {
  1032. X+     if (i == SIGINT)        /* Need this because swapper sets it    */
  1033. X+     SW_intr = 0;
  1034. X+ 
  1035. X      trapset = i;
  1036. X      signal (i, sig);
  1037. X  }
  1038. X***************
  1039. X*** 778,784 ****
  1040. X      unset (tval, TRUE);
  1041. X      }
  1042. X  
  1043. X!     RUN (aword, trapstr, nlchar);
  1044. X  }
  1045. X  
  1046. X  /*
  1047. X--- 753,759 ----
  1048. X      unset (tval, TRUE);
  1049. X      }
  1050. X  
  1051. X!     RUN (aword, trapstr, nlchar, TRUE);
  1052. X  }
  1053. X  
  1054. X  /*
  1055. X***************
  1056. X*** 858,864 ****
  1057. X   * give variable at `vp' the value `val'.
  1058. X   */
  1059. X  
  1060. X! void        setval(vp, val)
  1061. X  Var_List    *vp;
  1062. X  char        *val;
  1063. X  {
  1064. X--- 833,839 ----
  1065. X   * give variable at `vp' the value `val'.
  1066. X   */
  1067. X  
  1068. X! void        setval (vp, val)
  1069. X  Var_List    *vp;
  1070. X  char        *val;
  1071. X  {
  1072. X***************
  1073. X*** 911,917 ****
  1074. X  
  1075. X  /* Check for $PATH reset in restricted shell */
  1076. X  
  1077. X!     if (!disable && (strcmp (vp->name, Path) == 0) && check_rsh (Path))
  1078. X      return;
  1079. X  
  1080. X  /* Get space for string ? */
  1081. X--- 886,892 ----
  1082. X  
  1083. X  /* Check for $PATH reset in restricted shell */
  1084. X  
  1085. X!     if (!disable && (strncmp (vp->name, "PATH=", 5) == 0) && check_rsh (Path))
  1086. X      return;
  1087. X  
  1088. X  /* Get space for string ? */
  1089. X***************
  1090. X*** 941,948 ****
  1091. X  
  1092. X      if (FL_TEST ('a'))
  1093. X      s_vstatus (vp, EXPORT);
  1094. X- }
  1095. X  
  1096. X  /*
  1097. X   * Set the status of an environment variable
  1098. X   */
  1099. X--- 916,928 ----
  1100. X  
  1101. X      if (FL_TEST ('a'))
  1102. X      s_vstatus (vp, EXPORT);
  1103. X  
  1104. X+ /* Convert UNIX to DOS for PATH variable */
  1105. X+ 
  1106. X+     if (vp == path)
  1107. X+     U2D_Path ();
  1108. X+ }
  1109. X+ 
  1110. X  /*
  1111. X   * Set the status of an environment variable
  1112. X   */
  1113. X***************
  1114. X*** 1425,1437 ****
  1115. X          *s = tolower(*s);
  1116. X  
  1117. X          if (*s == '%')
  1118. X!         S_putc ('%');
  1119. X  
  1120. X          else
  1121. X          {
  1122. X          *buf = 0;
  1123. X  
  1124. X!         switch (*s)
  1125. X          {
  1126. X              case 'e':            /* Current event number */
  1127. X              if (History_Enabled)
  1128. X--- 1405,1417 ----
  1129. X          *s = tolower(*s);
  1130. X  
  1131. X          if (*s == '%')
  1132. X!         v1_putc ('%');
  1133. X  
  1134. X          else
  1135. X          {
  1136. X          *buf = 0;
  1137. X  
  1138. X!         switch (*(s++))
  1139. X          {
  1140. X              case 'e':            /* Current event number */
  1141. X              if (History_Enabled)
  1142. X***************
  1143. X*** 1453,1459 ****
  1144. X              case 'n':            /* default drive */
  1145. X              strcpy (buf, C_dir->value);
  1146. X  
  1147. X!             if (*s == 'n')
  1148. X                  buf[1] = 0;
  1149. X  
  1150. X              break;
  1151. X--- 1433,1439 ----
  1152. X              case 'n':            /* default drive */
  1153. X              strcpy (buf, C_dir->value);
  1154. X  
  1155. X!             if (*(s - 1) == 'n')
  1156. X                  buf[1] = 0;
  1157. X  
  1158. X              break;
  1159. X***************
  1160. X*** 1465,1471 ****
  1161. X  
  1162. X  /* Output the string */
  1163. X  
  1164. X!         S_puts (buf);
  1165. X          }
  1166. X      }
  1167. X  
  1168. X--- 1445,1451 ----
  1169. X  
  1170. X  /* Output the string */
  1171. X  
  1172. X!         v1_puts (buf);
  1173. X          }
  1174. X      }
  1175. X  
  1176. X***************
  1177. X*** 1473,1490 ****
  1178. X  
  1179. X      else if (*s == '\\')
  1180. X      {
  1181. X          if ((i = Process_Escape (&s)) == -1)
  1182. X          i = 0;
  1183. X  
  1184. X!         S_putc (i);
  1185. X      }
  1186. X  
  1187. X      else
  1188. X!         S_putc (*s);
  1189. X! 
  1190. X! /* Go to the next character */
  1191. X! 
  1192. X!     s++;
  1193. X      }
  1194. X  }
  1195. X  
  1196. X--- 1453,1467 ----
  1197. X  
  1198. X      else if (*s == '\\')
  1199. X      {
  1200. X+         ++s;
  1201. X          if ((i = Process_Escape (&s)) == -1)
  1202. X          i = 0;
  1203. X  
  1204. X!         v1_putc ((char)i);
  1205. X      }
  1206. X  
  1207. X      else
  1208. X!         v1_putc (*(s++));
  1209. X      }
  1210. X  }
  1211. X  
  1212. X***************
  1213. X*** 1496,1544 ****
  1214. X  void    Getcwd ()
  1215. X  {
  1216. X      char    ldir[PATH_MAX + 6];
  1217. X-     char    *cp = getcwd (ldir, PATH_MAX + 4);
  1218. X  
  1219. X!     strlwr (cp);
  1220. X  
  1221. X  /* Convert to Unix format */
  1222. X  
  1223. X!     while (*cp)
  1224. X!     {
  1225. X!     if (*cp == '\\')
  1226. X!         *cp = '/';
  1227. X  
  1228. X-     ++cp;
  1229. X-     }
  1230. X- 
  1231. X  /* Save in environment */
  1232. X  
  1233. X      setval ((C_dir = lookup ("~", TRUE)), ldir);
  1234. X  }
  1235. X  
  1236. X  /*
  1237. X!  * Patch up various parts of the system for the shell.  At the moment, we
  1238. X!  * modify the ctype table so that _ is an upper case character.
  1239. X   */
  1240. X  
  1241. X! static void    patch_up ()
  1242. X  {
  1243. X! /* Patch the ctype table as a cheat */
  1244. X  
  1245. X      (_ctype+1)['_'] |= _UPPER;
  1246. X  
  1247. X! /* Save the interrupt 24 address */
  1248. X  
  1249. X!     SW_I24_V = _dos_getvect (0x24);
  1250. X! 
  1251. X! /* Set the newinterrupt 24 address */
  1252. X! 
  1253. X      _dos_setvect (0x24, SW_Int24);
  1254. X- }
  1255. X  
  1256. X  /*
  1257. X   * Mail Check processing.  Every $MAILCHECK seconds, we check either $MAIL
  1258. X   * or $MAILPATH to see if any file has changed its modification time since
  1259. X!  * we last looked.  In $MAILCHECK, the files are separated by colons (:).
  1260. X   * If the filename contains a %, the string following the % is the message
  1261. X   * to display if the file has changed.
  1262. X   */
  1263. X--- 1473,1625 ----
  1264. X  void    Getcwd ()
  1265. X  {
  1266. X      char    ldir[PATH_MAX + 6];
  1267. X  
  1268. X!     getcwd (ldir, PATH_MAX + 4);
  1269. X!     ldir[PATH_MAX + 5] = 0;
  1270. X  
  1271. X  /* Convert to Unix format */
  1272. X  
  1273. X!     Convert_Backslashes (strlwr (ldir));
  1274. X  
  1275. X  /* Save in environment */
  1276. X  
  1277. X      setval ((C_dir = lookup ("~", TRUE)), ldir);
  1278. X  }
  1279. X  
  1280. X  /*
  1281. X!  * Initialise the shell and Patch up various parts of the system for the
  1282. X!  * shell.  At the moment, we modify the ctype table so that _ is an upper
  1283. X!  * case character.
  1284. X   */
  1285. X  
  1286. X! static bool    Initialise (name)
  1287. X! char        *name;
  1288. X  {
  1289. X!     register char    *s, *s1;
  1290. X!     char        **ap;
  1291. X!     Var_List        *lset;
  1292. X!     bool        l_rflag = FALSE;
  1293. X  
  1294. X+ /* Patch the ctype table as a cheat */
  1295. X+ 
  1296. X      (_ctype+1)['_'] |= _UPPER;
  1297. X  
  1298. X! /* Get original interrupt 24 address and set up our new interrupt 24
  1299. X!  * address
  1300. X!  */
  1301. X  
  1302. X!     Orig_I24_V = _dos_getvect (0x24);
  1303. X      _dos_setvect (0x24, SW_Int24);
  1304. X  
  1305. X+ /* Load the environment into our structures */
  1306. X+ 
  1307. X+     if ((ap = environ) != (char **)NULL)
  1308. X+     {
  1309. X+     while (*ap)
  1310. X+         assign (*ap++, !COPYV);
  1311. X+ 
  1312. X+     for (ap = environ; *ap;)
  1313. X+         s_vstatus (lookup (*ap++, TRUE), EXPORT);
  1314. X+     }
  1315. X+ 
  1316. X+ /* Change COMSPEC to unix format for execution */
  1317. X+ 
  1318. X+     lset = lookup ("COMSPEC", FALSE);
  1319. X+     Convert_Backslashes (lset->value);
  1320. X+     s_vstatus (lset, C_MSDOS);
  1321. X+ 
  1322. X+ /* Zap all files */
  1323. X+ 
  1324. X+     closeall ();
  1325. X+     areanum = 1;
  1326. X+ 
  1327. X+ /* Get the current directory */
  1328. X+ 
  1329. X+     Getcwd ();
  1330. X+ 
  1331. X+ /* Set up SHELL variable.  First check for a restricted shell.  Check the
  1332. X+  * restricted shell
  1333. X+  */
  1334. X+ 
  1335. X+     Program_Name = name;
  1336. X+     if ((s = strrchr (name, '/')) == (char *)NULL)
  1337. X+     s = name;
  1338. X+ 
  1339. X+     if ((s1 = strchr (s, '.')) != (char *)NULL)
  1340. X+     *s1 = 0;
  1341. X+ 
  1342. X+     if (strcmp (s, "rsh") == 0)
  1343. X+     l_rflag = TRUE;
  1344. X+ 
  1345. X+ /* Has the program name got a .exe extension - Yes probably DOS 3+.  So
  1346. X+  * save it as the Shell name
  1347. X+  */
  1348. X+ 
  1349. X+     lset = lookup (shell, TRUE);
  1350. X+ 
  1351. X+     if (s1 != (char *)NULL)
  1352. X+     {
  1353. X+     if ((stricmp (s1 + 1, "exe") == 0) && (lset->value == null))
  1354. X+         setval (lset, name);
  1355. X+ 
  1356. X+     *s1 = '.';
  1357. X+     }
  1358. X+ 
  1359. X+ /* Default if necessary */
  1360. X+ 
  1361. X+     if (lset->value == null)
  1362. X+     setval (lset, shellname);
  1363. X+ 
  1364. X+     Convert_Backslashes (lset->value);
  1365. X+     s_vstatus (lset, EXPORT);
  1366. X+ 
  1367. X+ /* Check for restricted shell */
  1368. X+ 
  1369. X+     if ((s = strrchr (lset->value, '/')) == (char *)NULL)
  1370. X+     s = lset->value;
  1371. X+ 
  1372. X+     else
  1373. X+     s++;
  1374. X+ 
  1375. X+     if (*s == 'r')
  1376. X+     l_rflag = TRUE;
  1377. X+ 
  1378. X+ /* Set up home directory */
  1379. X+ 
  1380. X+     if ((lset = lookup (home, TRUE))->value == null)
  1381. X+     setval (lset, C_dir->value);
  1382. X+ 
  1383. X+     s_vstatus (lset, EXPORT);
  1384. X+ 
  1385. X+ /* Set up history file location */
  1386. X+ 
  1387. X+     setval (lookup ("$", TRUE), putn (getpid ()));
  1388. X+ 
  1389. X+     Load_G_VL ();
  1390. X+     path->status |= (EXPORT | PONLY);
  1391. X+     ifs->status  |= (EXPORT | PONLY);
  1392. X+     ps1->status  |= (EXPORT | PONLY);
  1393. X+     ps2->status  |= (EXPORT | PONLY);
  1394. X+ 
  1395. X+     if (path->value == null)
  1396. X+     setval (path, search);
  1397. X+ 
  1398. X+     if (ifs->value == null)
  1399. X+     setval (ifs, " \t\n");
  1400. X+ 
  1401. X+     if (ps1->value == null)
  1402. X+     setval (ps1, "$ ");
  1403. X+ 
  1404. X+     if (ps2->value == null)
  1405. X+     setval (ps2, "> ");
  1406. X+ 
  1407. X+     return l_rflag;
  1408. X+ }
  1409. X+ 
  1410. X  /*
  1411. X   * Mail Check processing.  Every $MAILCHECK seconds, we check either $MAIL
  1412. X   * or $MAILPATH to see if any file has changed its modification time since
  1413. X!  * we last looked.  In $MAILCHECK, the files are separated by semi-colon (;).
  1414. X   * If the filename contains a %, the string following the % is the message
  1415. X   * to display if the file has changed.
  1416. X   */
  1417. X***************
  1418. X*** 1571,1577 ****
  1419. X  
  1420. X  /* Look for the next separator */
  1421. X  
  1422. X!     while ((cp = strchr (sp, ':')) != (char *)NULL)
  1423. X      {
  1424. X          *cp = 0;
  1425. X  
  1426. X--- 1652,1658 ----
  1427. X  
  1428. X  /* Look for the next separator */
  1429. X  
  1430. X!     while ((cp = strchr (sp, ';')) != (char *)NULL)
  1431. X      {
  1432. X          *cp = 0;
  1433. X  
  1434. X***************
  1435. X*** 1599,1607 ****
  1436. X          if (ap != (char *)NULL)
  1437. X          *ap = '%';
  1438. X  
  1439. X! /* Restore the colon and find the next one */
  1440. X  
  1441. X!         *cp = ':';
  1442. X          sp = cp + 1;
  1443. X      }
  1444. X      }
  1445. X--- 1680,1688 ----
  1446. X          if (ap != (char *)NULL)
  1447. X          *ap = '%';
  1448. X  
  1449. X! /* Restore the semi-colon and find the next one */
  1450. X  
  1451. X!         *cp = ';';
  1452. X          sp = cp + 1;
  1453. X      }
  1454. X      }
  1455. X***************
  1456. X*** 1674,1677 ****
  1457. X--- 1755,1866 ----
  1458. X          return;
  1459. X         }
  1460. X      }
  1461. X+ }
  1462. X+ 
  1463. X+ /*
  1464. X+  * Convert backslashes to slashes for UNIX
  1465. X+  */
  1466. X+ 
  1467. X+ static void    Convert_Backslashes (sp)
  1468. X+ char        *sp;
  1469. X+ {
  1470. X+     while (*sp)
  1471. X+     {
  1472. X+     if (*sp == '\\')
  1473. X+         *sp = '/';
  1474. X+ 
  1475. X+     ++sp;
  1476. X+     }
  1477. X+ }
  1478. X+ 
  1479. X+ /* Load profiles onto I/O Stack */
  1480. X+ 
  1481. X+ static void    Load_profiles ()
  1482. X+ {
  1483. X+     char    *name;
  1484. X+     int        f;
  1485. X+ 
  1486. X+ /* Set up home profile */
  1487. X+ 
  1488. X+     name = Build_H_Filename ("profile");
  1489. X+ 
  1490. X+     talking = TRUE;
  1491. X+ 
  1492. X+     if ((f = O_for_execute (name, (char **)NULL, (int *)NULL)) >= 0)
  1493. X+     {
  1494. X+     PUSHIO (afile, remap (f), filechar);
  1495. X+     }
  1496. X+ 
  1497. X+     DELETE (name);
  1498. X+ 
  1499. X+     if ((f = O_for_execute ("/etc/profile", (char **)NULL, (int *)NULL)) >= 0)
  1500. X+     {
  1501. X+     PUSHIO (afile, remap (f), filechar);
  1502. X+     }
  1503. X+ }
  1504. X+ 
  1505. X+ /*
  1506. X+  * Convert Unix PATH to MSDOS PATH
  1507. X+  */
  1508. X+ 
  1509. X+ static void    U2D_Path ()
  1510. X+ {
  1511. X+     char    *cp = path->value;
  1512. X+     int        colon = 0;
  1513. X+ 
  1514. X+ /* If there is a semi-colon or a backslash, we assume this is a DOS format
  1515. X+  * path
  1516. X+  */
  1517. X+ 
  1518. X+     if ((strchr (cp, ';') != (char *)NULL) ||
  1519. X+     (strchr (cp, '\\') != (char *)NULL))
  1520. X+     return;
  1521. X+ 
  1522. X+ /* Count the number of colons */
  1523. X+ 
  1524. X+     while ((cp = strchr (cp, ':')) != (char *)NULL)
  1525. X+     {
  1526. X+     ++colon;
  1527. X+     ++cp;
  1528. X+     }
  1529. X+ 
  1530. X+ /* If there are no colons or there is one colon as the second character, it
  1531. X+  * is probably an MSDOS path
  1532. X+  */
  1533. X+ 
  1534. X+     cp = path->value;
  1535. X+     if ((colon == 0) || ((colon == 1) && (*(cp + 1) == ':')))
  1536. X+     return;
  1537. X+ 
  1538. X+ /* Otherwise, convert all colons to semis */
  1539. X+ 
  1540. X+     while ((cp = strchr (cp, ':')) != (char *)NULL)
  1541. X+     *(cp++) = ';';
  1542. X+ }
  1543. X+ 
  1544. X+ /* Generate a file name from a directory and name.  Return null if an error
  1545. X+  * occurs or some malloced space containing the file name otherwise
  1546. X+  */
  1547. X+ 
  1548. X+ char    *Build_H_Filename (name)
  1549. X+ char    *name;
  1550. X+ {
  1551. X+     char    *dir = lookup (home, FALSE)->value;
  1552. X+     char    *cp;
  1553. X+ 
  1554. X+ /* Get some space */
  1555. X+ 
  1556. X+     if ((cp = getcell (strlen (dir) + strlen (name) + 2)) == (char *)NULL)
  1557. X+     return null;
  1558. X+ 
  1559. X+ /* Addend the directory and a / if the directory does not end in one */
  1560. X+ 
  1561. X+     strcpy (cp, dir);
  1562. X+ 
  1563. X+     if (cp[strlen (cp) - 1] != '/')
  1564. X+     strcat (cp, "/");
  1565. X+ 
  1566. X+ /* Append the file name */
  1567. X+ 
  1568. X+     return strcat (cp, name);
  1569. X  }
  1570. XIndex: Install
  1571. XPrereq: 1.1
  1572. X*** ../sh15/Install    Fri Mar  2 11:25:07 1990
  1573. X--- Install    Fri Apr  6 17:57:25 1990
  1574. X***************
  1575. X*** 1,4 ****
  1576. X!  MS-DOS Shell Version 1.4    INSTALL                January 1990
  1577. X  
  1578. X   MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
  1579. X  
  1580. X--- 1,4 ----
  1581. X!  MS-DOS Shell Version 1.6    INSTALL                April 1990
  1582. X  
  1583. X   MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
  1584. X  
  1585. X***************
  1586. X*** 13,24 ****
  1587. X   2.  The sources (or parts thereof) or objects generated from the
  1588. X       sources (or parts of sources) cannot be sold under any circumstances.
  1589. X  
  1590. X!     $Header: install 1.1 90/01/29 18:03:04 MS_user Exp $
  1591. X  
  1592. X      $Log:    install $
  1593. X! # Revision 1.1  90/01/29  18:03:04  MS_user
  1594. X! # Initial revision
  1595. X! # 
  1596. X  ________________________________________________________________________________
  1597. X  
  1598. X  To rebuild and install the shell, you should follow the following the
  1599. X--- 13,27 ----
  1600. X   2.  The sources (or parts thereof) or objects generated from the
  1601. X       sources (or parts of sources) cannot be sold under any circumstances.
  1602. X  
  1603. X!     $Header: install 1.2 90/04/03 18:03:28 MS_user Exp $
  1604. X  
  1605. X      $Log:    install $
  1606. X!     Revision 1.2  90/04/03  18:03:28  MS_user
  1607. X!     Upgrade for 1.6
  1608. X!     
  1609. X!     Revision 1.1  90/01/29  18:03:04  MS_user
  1610. X!     Initial revision
  1611. X!     
  1612. X  ________________________________________________________________________________
  1613. X  
  1614. X  To rebuild and install the shell, you should follow the following the
  1615. X***************
  1616. X*** 42,48 ****
  1617. X      the bottom three bits, noted the bytes around this location,
  1618. X      extracted the open function from the library, patched the mask
  1619. X      to be 0x83 instead of 0x03, and then replaced the function in the
  1620. X!     library.
  1621. X  
  1622. X  3)  Compile the library files in the directory /lib in large model mode
  1623. X      and add the objects to your large model library
  1624. X--- 45,51 ----
  1625. X      the bottom three bits, noted the bytes around this location,
  1626. X      extracted the open function from the library, patched the mask
  1627. X      to be 0x83 instead of 0x03, and then replaced the function in the
  1628. X!     library (Also see the Patch.Lib file).
  1629. X  
  1630. X  3)  Compile the library files in the directory /lib in large model mode
  1631. X      and add the objects to your large model library
  1632. X***************
  1633. X*** 61,67 ****
  1634. X  
  1635. X      Install the shell in its correct location.
  1636. X  
  1637. X! 5)  Modify the scripts as appropriate for your installation and install
  1638. X!     them in the correct directories.
  1639. X  
  1640. X! 6)  Type "sh -0" and see what happens.
  1641. X--- 64,72 ----
  1642. X  
  1643. X      Install the shell in its correct location.
  1644. X  
  1645. X! 5)  Modify the initialisation file sh.ini for your edit key preferences.
  1646. X  
  1647. X! 6)  Modify the scripts as appropriate for your installation and install
  1648. X!     them in the correct directories.
  1649. X! 
  1650. X! 7)  Type "sh -0" and see what happens.
  1651. XIndex: MANIFEST
  1652. X*** ../sh15/MANIFEST    Fri Mar  9 13:52:35 1990
  1653. X--- MANIFEST    Thu Mar 15 09:35:19 1990
  1654. X***************
  1655. X*** 1,8 ****
  1656. X  Install            | Installation instructions
  1657. X  MANIFEST        | This list
  1658. X! Notes            | Some addition notes for release
  1659. X  ReadMe            | The Release Readme
  1660. X  sh.1            | The Manual page in *roff format
  1661. X  include/Changes        | Changes to standard include files
  1662. X  include/dirent.h    | Directory (3) functions include
  1663. X  include/unistd.h    | unistd for MSDOS
  1664. X--- 1,12 ----
  1665. X  Install            | Installation instructions
  1666. X  MANIFEST        | This list
  1667. X! Notes1.4        | Some addition notes for release 1.4
  1668. X! Notes1.5        | Some addition notes for release 1.5
  1669. X! Notes1.6        | Some addition notes for release 1.6
  1670. X  ReadMe            | The Release Readme
  1671. X  sh.1            | The Manual page in *roff format
  1672. X+ ms_dio.2        | The Manual page for ms_dio.c in *roff format
  1673. X+ Patch.Lib        | Instructions for patching open.obj for O_NOINHERIT
  1674. X  include/Changes        | Changes to standard include files
  1675. X  include/dirent.h    | Directory (3) functions include
  1676. X  include/unistd.h    | unistd for MSDOS
  1677. X***************
  1678. X*** 13,24 ****
  1679. X  lib/director.c        | POSIX directory (3) functions for MSDOS
  1680. X  lib/popen.c        | popen/pclose for MSDOS
  1681. X  lib/syserr.c        | Modified sys_errlist for MSDOS
  1682. X! lib/stdargv.c        | Replacement command list processing for programes
  1683. X  lib/pnmatch.c        | Pattern matching function
  1684. X  lib/getopt.c        | getopt function
  1685. X  scripts/l        | A sample shell script
  1686. X  scripts/extend.lst    | A sample extended command line processing list
  1687. X  scripts/profile.sh    | A sample start up shell script
  1688. X  shell/Makefile        | Shell - makefile 
  1689. X  shell/sh0.asm        | Shell - Swap functions
  1690. X  shell/sh1.c        | Shell - Main program and memory control functions
  1691. X--- 17,29 ----
  1692. X  lib/director.c        | POSIX directory (3) functions for MSDOS
  1693. X  lib/popen.c        | popen/pclose for MSDOS
  1694. X  lib/syserr.c        | Modified sys_errlist for MSDOS
  1695. X! lib/stdargv.c        | Replacement command list processing for programme
  1696. X  lib/pnmatch.c        | Pattern matching function
  1697. X  lib/getopt.c        | getopt function
  1698. X  scripts/l        | A sample shell script
  1699. X  scripts/extend.lst    | A sample extended command line processing list
  1700. X  scripts/profile.sh    | A sample start up shell script
  1701. X+ scripts/sh.ini        | A sample shell initialisation file
  1702. X  shell/Makefile        | Shell - makefile 
  1703. X  shell/sh0.asm        | Shell - Swap functions
  1704. X  shell/sh1.c        | Shell - Main program and memory control functions
  1705. XIndex: ReadMe
  1706. XPrereq: 1.3
  1707. X*** ../sh15/ReadMe    Wed Mar  7 11:08:34 1990
  1708. X--- ReadMe    Fri Apr  6 17:58:18 1990
  1709. X***************
  1710. X*** 1,4 ****
  1711. X!  MS-DOS Shell Version 1.5    README                February 1990
  1712. X  
  1713. X   MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
  1714. X  
  1715. X--- 1,4 ----
  1716. X!  MS-DOS Shell Version 1.6    README                April 1990
  1717. X  
  1718. X   MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
  1719. SHAR_EOF
  1720. echo "End of part 6"
  1721. echo "File Patch1.6 is continued in part 7"
  1722. echo "7" > s2_seq_.tmp
  1723. exit 0
  1724.  
  1725.  
  1726.