home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume12 / ms_sh-1.6 / part06 < prev    next >
Encoding:
Text File  |  1990-05-05  |  38.2 KB  |  1,733 lines

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