home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-05-06 | 37.9 KB | 1,726 lines |
-
- #!/bin/sh
- # this is part 6 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file Patch1.6 continued
- #
- CurArch=6
- if test ! -r s2_seq_.tmp
- then echo "Please unpack part 1 first!"
- exit 1; fi
- ( read Scheck
- if test "$Scheck" != $CurArch
- then echo "Please unpack part $Scheck next!"
- exit 1;
- else exit 0; fi
- ) < s2_seq_.tmp || exit 1
- echo "x - Continuing file Patch1.6"
- sed 's/^X//' << 'SHAR_EOF' >> Patch1.6
- X! */
- X
- X+ if (strnicmp (name, "/dev/", 5) == 0)
- X+ {
- X+ if (stricmp (&name[5], "tty") == 0)
- X+ strcpy (&name[5], "con");
- X+
- X+ else if (stricmp (&name[5], "null") == 0)
- X+ strcpy (&name[5], "nul");
- X+
- X+ mode &= ~(O_CREAT | O_TRUNC);
- X+ }
- X+
- X fp->fl_name = strcpy (f_name, name);
- X fp->fl_close = d_flag;
- X fp->fl_size = F_START;
- X***************
- X*** 260,266 ****
- X * Add the ID to the ID array for this file
- X */
- X
- X! void S_Remap (old_fid, new_fid)
- X int old_fid, new_fid;
- X {
- X s_flist *fp = find_entry (old_fid);
- X--- 297,303 ----
- X * Add the ID to the ID array for this file
- X */
- X
- X! int S_Remap (old_fid, new_fid)
- X int old_fid, new_fid;
- X {
- X s_flist *fp = find_entry (old_fid);
- X***************
- X*** 268,284 ****
- X int i;
- X
- X if (fp == (s_flist *)NULL)
- X! return;
- X
- X /* Is there an empty slot ? */
- X
- X for (i = 0; i < fp->fl_count; i++)
- X {
- X if (fp->fl_fd[i] == -1)
- X! {
- X! fp->fl_fd[i] = new_fid;
- X! return;
- X! }
- X }
- X
- X /* Is there any room at the end ? No - grap somemore space and effect a
- X--- 305,318 ----
- X int i;
- X
- X if (fp == (s_flist *)NULL)
- X! return new_fid;
- X
- X /* Is there an empty slot ? */
- X
- X for (i = 0; i < fp->fl_count; i++)
- X {
- X if (fp->fl_fd[i] == -1)
- X! return (fp->fl_fd[i] = new_fid);
- X }
- X
- X /* Is there any room at the end ? No - grap somemore space and effect a
- X***************
- X*** 290,296 ****
- X {
- X if ((flist = (int *) space ((fp->fl_size + F_START) * sizeof (int)))
- X == (int *)NULL)
- X! return;
- X
- X memcpy ((char *)flist, (char *)fp->fl_fd, sizeof (int) * fp->fl_size);
- X DELETE (fp->fl_fd);
- X--- 324,330 ----
- X {
- X if ((flist = (int *) space ((fp->fl_size + F_START) * sizeof (int)))
- X == (int *)NULL)
- X! return new_fid;
- X
- X memcpy ((char *)flist, (char *)fp->fl_fd, sizeof (int) * fp->fl_size);
- X DELETE (fp->fl_fd);
- X***************
- X*** 299,305 ****
- X fp->fl_size += F_START;
- X }
- X
- X! fp->fl_fd[fp->fl_count++] = new_fid;
- X }
- X
- X /*
- X--- 333,339 ----
- X fp->fl_size += F_START;
- X }
- X
- X! return (fp->fl_fd[fp->fl_count++] = new_fid);
- X }
- X
- X /*
- X***************
- X*** 323,329 ****
- X int old_fid;
- X int new_fid;
- X {
- X! int res = 0;
- X int i;
- X Save_IO *sp;
- X
- X--- 357,363 ----
- X int old_fid;
- X int new_fid;
- X {
- X! int res = -1;
- X int i;
- X Save_IO *sp;
- X
- X***************
- X*** 391,408 ****
- X if ((old_fid != -1) && ((res = dup2 (old_fid, new_fid)) >= 0))
- X {
- X S_close (new_fid, FALSE);
- X! S_Remap (old_fid, new_fid);
- X }
- X
- X return res;
- X }
- X
- X /*
- X! * Restore the Stdin, Stdout and Stderr to original values
- X */
- X
- X! int restore_std (rv)
- X int rv;
- X {
- X int j, i;
- X Save_IO *sp;
- X--- 425,444 ----
- X if ((old_fid != -1) && ((res = dup2 (old_fid, new_fid)) >= 0))
- X {
- X S_close (new_fid, FALSE);
- X! res = S_Remap (old_fid, new_fid);
- X }
- X
- X return res;
- X }
- X
- X /*
- X! * Restore the Stdin, Stdout and Stderr to original values. If change is
- X! * FALSE, just remove entries from stack. A special case for exec.
- X */
- X
- X! int restore_std (rv, change)
- X int rv;
- X+ bool change;
- X {
- X int j, i;
- X Save_IO *sp;
- X***************
- X*** 422,429 ****
- X
- X --NSave_IO_E;
- X
- X! /* Close and restore any files */
- X
- X for (i = STDIN_FILENO; i <= STDERR_FILENO; i++)
- X {
- X if (sp->fp[i] != -1)
- X--- 458,470 ----
- X
- X --NSave_IO_E;
- X
- X! /* If special case (changed at this level) - continue */
- X
- X+ if (!change && (sp->depth == Execute_stack_depth))
- X+ continue;
- X+
- X+ /* Close and restore any files */
- X+
- X for (i = STDIN_FILENO; i <= STDERR_FILENO; i++)
- X {
- X if (sp->fp[i] != -1)
- X***************
- X*** 504,553 ****
- X * handler for the file
- X */
- X
- X! int O_for_execute (path)
- X char *path;
- X {
- X! int i, end;
- X! char local_path[FFNAME_MAX];
- X
- X /* Work on a copy of the path */
- X
- X! strcpy (local_path, path);
- X
- X /* Try the file name and then with a .sh appended */
- X
- X! for (end = 0; end < 2; end++)
- X! {
- X! if ((i = Check_Script (local_path)) >= 0)
- X! return i;
- X
- X! if (!end)
- X! strcat (local_path, ".sh");
- X! }
- X!
- X! return -1;
- X }
- X
- X /*
- X * Check for shell script
- X */
- X
- X! int Check_Script (path)
- X char *path;
- X {
- X! char buf[5];
- X! int i;
- X
- X! if (((i = S_open (FALSE, path, O_RMASK)) >= 0) &&
- X! ((read (i, buf, 6) == 5) && (strncmp (buf, "#!sh\n", 5) == 0)))
- X! return i;
- X
- X! if (i != -1)
- X! S_close (i, TRUE);
- X
- X! return -1;
- X! }
- X
- X /*
- X * Convert slashes to backslashes for MSDOS
- X */
- X--- 545,677 ----
- X * handler for the file
- X */
- X
- X! int O_for_execute (path, params, nargs)
- X char *path;
- X+ char **params;
- X+ int *nargs;
- X {
- X! int i = -1;
- X! char *local_path;
- X
- X /* Work on a copy of the path */
- X
- X! if ((local_path = getcell (strlen (path) + 4)) == (char *)NULL)
- X! return -1;
- X
- X /* Try the file name and then with a .sh appended */
- X
- X! if ((i = Check_Script (strcpy (local_path, path), params, nargs)) < 0)
- X! i = Check_Script (strcat (local_path, ".sh"), params, nargs);
- X
- X! DELETE (local_path);
- X! return i;
- X }
- X
- X /*
- X * Check for shell script
- X */
- X
- X! int Check_Script (path, params, nargs)
- X char *path;
- X+ char **params;
- X+ int *nargs;
- X {
- X! char buf[512]; /* Input buffer */
- X! int fp; /* File handler */
- X! int nbytes; /* Number of bytes read */
- X! char *bp; /* Pointers into buffers */
- X! char *ep;
- X
- X! if ((fp = S_open (FALSE, path, O_RMASK)) < 0)
- X! return -1;
- X
- X! /* zero or less bytes - not a script */
- X
- X! memset (buf, 0, 512);
- X! nbytes = read (fp, buf, 512);
- X
- X+ for (ep = &buf[nbytes], bp = buf; (bp < ep) && ((unsigned char)*bp >= 0x08); ++bp);
- X+
- X+ /* If non-ascii file or lenght is less than 1 - not a script */
- X+
- X+ if ((bp != ep) || (nbytes < 1))
- X+ {
- X+ S_close (fp, TRUE);
- X+ return -1;
- X+ }
- X+
- X+ /* Ensure end of buffer detected */
- X+
- X+ buf[511] = 0;
- X+
- X+ /* Initialise the return parameters, if specified */
- X+
- X+ if (params != (char **)NULL)
- X+ *params = null;
- X+
- X+ if (nargs != (int *)NULL)
- X+ *nargs = 0;
- X+
- X+ /* We don't care how many bytes were read now, so use it to count the
- X+ * additional arguments
- X+ */
- X+
- X+ nbytes = 0;
- X+
- X+ /* Find the end of the first line */
- X+
- X+ if ((bp = strchr (buf, '\n')) != (char *)NULL)
- X+ *bp = 0;
- X+
- X+ bp = buf;
- X+ ep = (char *)NULL;
- X+
- X+ /* Check for script */
- X+
- X+ if ((*(bp++) != '#') || (*(bp++) != '!'))
- X+ return fp;
- X+
- X+ while (*bp)
- X+ {
- X+ while (isspace (*bp))
- X+ ++bp;
- X+
- X+ /* Save the start of the arguments */
- X+
- X+ if (*bp)
- X+ {
- X+ if (ep == (char *)NULL)
- X+ ep = bp;
- X+
- X+ /* Count the arguments */
- X+
- X+ ++nbytes;
- X+ }
- X+
- X+ while (!isspace (*bp) && *bp)
- X+ ++bp;
- X+ }
- X+
- X+ /* Set up the return parameters, if appropriate */
- X+
- X+ if ((params != (char **)NULL) && (strlen (ep) != 0))
- X+ {
- X+ if ((*params = getcell (strlen (ep) + 1)) == (char *)NULL)
- X+ {
- X+ *params = null;
- X+ S_close (fp, TRUE);
- X+ return -1;
- X+ }
- X+
- X+ strcpy (*params, ep);
- X+ }
- X+
- X+ if (nargs != (int *)NULL)
- X+ *nargs = nbytes;
- X+
- X+ return fp;
- X+ }
- X+
- X /*
- X * Convert slashes to backslashes for MSDOS
- X */
- X***************
- X*** 561,565 ****
- X--- 685,767 ----
- X *sp = '\\';
- X
- X ++sp;
- X+ }
- X+ }
- X+
- X+ /*
- X+ * Some buffered Output functions to speed somethings up.
- X+ */
- X+
- X+ /* Open the buffer */
- X+
- X+ Out_Buf *Open_buffer (fid, f_abort)
- X+ int fid;
- X+ bool f_abort;
- X+ {
- X+ Out_Buf *bp;
- X+
- X+ if (((bp = (Out_Buf *)getcell (sizeof (Out_Buf))) == (Out_Buf *)NULL) ||
- X+ ((bp->ob_start = getcell (BIO_LENGTH)) == (char *)NULL))
- X+ {
- X+ if (f_abort)
- X+ {
- X+ print_error ("sh: %s\n", strerror (ENOMEM));
- X+ fail ();
- X+ }
- X+
- X+ return (Out_Buf *)NULL;
- X+ }
- X+
- X+ /* Ok - save info */
- X+
- X+ bp->ob_fid = fid;
- X+ bp->ob_cur = bp->ob_start;
- X+ return bp;
- X+ }
- X+
- X+ /* Add a character to the buffer */
- X+
- X+ void Add_buffer (c, bp)
- X+ char c;
- X+ Out_Buf *bp;
- X+ {
- X+ *(bp->ob_cur++) = c;
- X+
- X+ if (bp->ob_cur == &bp->ob_start[BIO_LENGTH - 1])
- X+ {
- X+ write (bp->ob_fid, bp->ob_start, BIO_LENGTH - 1);
- X+ bp->ob_cur = bp->ob_start;
- X+ }
- X+ }
- X+
- X+ /* Close the buffer */
- X+
- X+ void Close_buffer (bp)
- X+ Out_Buf *bp;
- X+ {
- X+ int n;
- X+
- X+ if ((n = (int)(bp->ob_cur - bp->ob_start)))
- X+ write (bp->ob_fid, bp->ob_start, n);
- X+
- X+ DELETE (bp->ob_start);
- X+ DELETE (bp);
- X+ }
- X+
- X+ /* Output string */
- X+
- X+ void Adds_buffer (s, bp)
- X+ char *s;
- X+ Out_Buf *bp;
- X+ {
- X+ while (*s)
- X+ {
- X+ *(bp->ob_cur++) = *(s++);
- X+
- X+ if (bp->ob_cur == &bp->ob_start[BIO_LENGTH - 1])
- X+ {
- X+ write (bp->ob_fid, bp->ob_start, BIO_LENGTH - 1);
- X+ bp->ob_cur = bp->ob_start;
- X+ }
- X }
- X }
- XIndex: shell/sh1.c
- XPrereq: 1.2
- X*** ../sh15/shell/sh1.c Fri Feb 16 19:12:27 1990
- X--- shell/sh1.c Tue May 1 19:48:00 1990
- X***************
- X*** 13,21 ****
- X * 2. The sources (or parts thereof) or objects generated from the sources
- X * (or parts of sources) cannot be sold under any circumstances.
- X *
- X! * $Header: sh1.c 1.2 90/02/14 04:46:20 MS_user Exp $
- X *
- X * $Log: sh1.c $
- X * Revision 1.2 90/02/14 04:46:20 MS_user
- X * Add Interrupt 24 processing
- X *
- X--- 13,60 ----
- X * 2. The sources (or parts thereof) or objects generated from the sources
- X * (or parts of sources) cannot be sold under any circumstances.
- X *
- X! * $Header: sh1.c 1.14 90/04/25 22:33:28 MS_user Exp $
- X *
- X * $Log: sh1.c $
- X+ * Revision 1.14 90/04/25 22:33:28 MS_user
- X+ * Fix rsh check for PATH
- X+ *
- X+ * Revision 1.13 90/04/25 09:18:12 MS_user
- X+ * Change version message processing
- X+ *
- X+ * Revision 1.12 90/04/04 11:32:12 MS_user
- X+ * Change MAILPATH to use a semi-colon and not a colon for DOS
- X+ *
- X+ * Revision 1.11 90/04/03 17:58:35 MS_user
- X+ * Stop shell exit from lowest level CLI
- X+ *
- X+ * Revision 1.10 90/03/27 20:24:49 MS_user
- X+ * Fix problem with Interrupts not restoring std??? and clearing extended file
- X+ *
- X+ * Revision 1.9 90/03/26 20:56:13 MS_user
- X+ * Change I/O restore so that "exec >filename" works
- X+ *
- X+ * Revision 1.8 90/03/26 04:30:14 MS_user
- X+ * Remove original Interrupt 24 save address
- X+ *
- X+ * Revision 1.7 90/03/12 20:16:22 MS_user
- X+ * Save program name for Initialisation file processing
- X+ *
- X+ * Revision 1.6 90/03/09 16:05:33 MS_user
- X+ * Add build file name function and change the profile check to use it
- X+ *
- X+ * Revision 1.5 90/03/06 16:49:14 MS_user
- X+ * Add disable history option
- X+ *
- X+ * Revision 1.4 90/03/06 15:09:27 MS_user
- X+ * Add Unix PATH variable conversion
- X+ *
- X+ * Revision 1.3 90/03/05 13:47:45 MS_user
- X+ * Get /etc/profile and profile order rigth
- X+ * Use $HOME/profile and not profile
- X+ * Check cursor position before outputing prompt
- X+ * Move some of processing in main to sub-routines
- X+ *
- X * Revision 1.2 90/02/14 04:46:20 MS_user
- X * Add Interrupt 24 processing
- X *
- X***************
- X*** 61,68 ****
- X static char *search = ";c:/bin;c:/usr/bin";
- X static char *ymail = "You have mail\n";
- X static char *Path = "PATH";
- X #ifdef SIGQUIT
- X! static void (*qflag)() = SIG_IGN;
- X #endif
- X
- X /* Functions */
- X--- 100,109 ----
- X static char *search = ";c:/bin;c:/usr/bin";
- X static char *ymail = "You have mail\n";
- X static char *Path = "PATH";
- X+ /* Original Interrupt 24 address */
- X+ static void (interrupt far *Orig_I24_V) (void);
- X #ifdef SIGQUIT
- X! static void (*qflag)(int) = SIG_IGN;
- X #endif
- X
- X /* Functions */
- X***************
- X*** 70,80 ****
- X static char *cclass (char *, int, bool);
- X static char *copy_to_equals (char *, char *);
- X static void nameval (Var_List *, char *, char *, bool);
- X! static void patch_up (void);
- X static void onecommand (void);
- X static void Check_Mail (void);
- X static void Pre_Process_Argv (char **);
- X static void Load_G_VL (void);
- X
- X /*
- X * The main program starts here
- X--- 111,124 ----
- X static char *cclass (char *, int, bool);
- X static char *copy_to_equals (char *, char *);
- X static void nameval (Var_List *, char *, char *, bool);
- X! static bool Initialise (char *);
- X static void onecommand (void);
- X static void Check_Mail (void);
- X static void Pre_Process_Argv (char **);
- X static void Load_G_VL (void);
- X+ static void Convert_Backslashes (char *);
- X+ static void Load_profiles (void);
- X+ static void U2D_Path (void);
- X
- X /*
- X * The main program starts here
- X***************
- X*** 85,183 ****
- X register char **argv;
- X {
- X register int f;
- X- register char *s, *s1;
- X int cflag = 0;
- X int sc;
- X! char *name, **ap;
- X int (*iof)(IO_State *) = filechar;
- X! Var_List *lset;
- X! bool l_rflag = FALSE;
- X
- X- /* Patch up various parts of the system */
- X-
- X- patch_up ();
- X-
- X- /* Load the environment into our structures */
- X-
- X- if ((ap = environ) != (char **)NULL)
- X- {
- X- while (*ap)
- X- assign (*ap++, !COPYV);
- X-
- X- for (ap = environ; *ap;)
- X- s_vstatus (lookup (*ap++, TRUE), EXPORT);
- X- }
- X-
- X- /* Zap all files */
- X-
- X- closeall ();
- X- areanum = 1;
- X-
- X- /* Get the current directory */
- X-
- X- Getcwd ();
- X-
- X- /* Set up some stardard variables if their not set */
- X-
- X- if ((lset = lookup (shell, TRUE))->value == null)
- X- setval (lset, shellname);
- X-
- X- s_vstatus (lset, EXPORT);
- X-
- X- /* Check for restricted shell */
- X-
- X- if ((s = strrchr (lset->value, '/')) == (char *)NULL)
- X- s = lset->value;
- X-
- X- else
- X- s++;
- X-
- X- if (*s == 'r')
- X- l_rflag = TRUE;
- X-
- X- /* Set up home directory */
- X-
- X- if ((lset = lookup (home, TRUE))->value == null)
- X- setval (lset, "c:/");
- X-
- X- s_vstatus (lset, EXPORT);
- X-
- X- /* Set up history file location */
- X-
- X- setval (lookup ("$", TRUE), putn (getpid ()));
- X-
- X- Load_G_VL ();
- X- path->status |= (EXPORT | PONLY);
- X- ifs->status |= (EXPORT | PONLY);
- X- ps1->status |= (EXPORT | PONLY);
- X- ps2->status |= (EXPORT | PONLY);
- X-
- X- if (path->value == null)
- X- setval (path, search);
- X-
- X- if (ifs->value == null)
- X- setval (ifs, " \t\n");
- X-
- X- if (ps1->value == null)
- X- setval (ps1, "$ ");
- X-
- X- if (ps2->value == null)
- X- setval (ps2, "> ");
- X-
- X- /* Check the restricted shell */
- X-
- X- if ((s = strrchr ((name = *argv), '/')) == (char *)NULL)
- X- s = name;
- X-
- X- if ((s1 = strchr (s, '.')) != (char *)NULL)
- X- *s1 = 0;
- X-
- X- if (strcmp (s, "rsh") == 0)
- X- l_rflag = TRUE;
- X-
- X- if (s1 != (char *)NULL)
- X- *s1 = '.';
- X-
- X /* Preprocess options to convert two character options of the form /x to
- X * -x. Some programs!!
- X */
- X--- 129,143 ----
- X register char **argv;
- X {
- X register int f;
- X int cflag = 0;
- X int sc;
- X! char *name = *argv;
- X! char **ap;
- X int (*iof)(IO_State *) = filechar;
- X! /* Load up various parts of the */
- X! /* system */
- X! bool l_rflag = Initialise (*argv);
- X
- X /* Preprocess options to convert two character options of the form /x to
- X * -x. Some programs!!
- X */
- X***************
- X*** 224,230 ****
- X break;
- X
- X case 'i': /* Set interactive */
- X! talking++;
- X
- X default:
- X if (islower (sc))
- X--- 184,190 ----
- X break;
- X
- X case 'i': /* Set interactive */
- X! talking = TRUE;
- X
- X default:
- X if (islower (sc))
- X***************
- X*** 250,263 ****
- X
- X if (strcmp ((name = *argv), "-") != 0)
- X {
- X! if ((f = O_for_execute (name)) < 0)
- X {
- X print_error ("%s: cannot open\n", name);
- X exit (1);
- X }
- X }
- X
- X! next (remap (f)); /* Load into I/O stack */
- X }
- X
- X /* Set up the $- variable */
- X--- 210,223 ----
- X
- X if (strcmp ((name = *argv), "-") != 0)
- X {
- X! if ((f = O_for_execute (name, (char **)NULL, (int *)NULL)) < 0)
- X {
- X print_error ("%s: cannot open\n", name);
- X exit (1);
- X }
- X }
- X
- X! PUSHIO (afile, remap (f), filechar); /* Load into I/O stack */
- X }
- X
- X /* Set up the $- variable */
- X***************
- X*** 272,283 ****
- X
- X if (isatty (0) && isatty (1) && !cflag)
- X {
- X! fprintf (stderr, Copy_Right1, _osmajor, _osminor);
- X! fputs (Copy_Right2, stderr);
- X
- X! talking++;
- X History_Enabled = TRUE;
- X Load_History ();
- X }
- X }
- X
- X--- 232,245 ----
- X
- X if (isatty (0) && isatty (1) && !cflag)
- X {
- X! Print_Version (2);
- X
- X! talking = TRUE;
- X! #ifndef NO_HISTORY
- X History_Enabled = TRUE;
- X Load_History ();
- X+ Configure_Keys ();
- X+ #endif
- X }
- X }
- X
- X***************
- X*** 288,303 ****
- X /* Read profile ? */
- X
- X if (((name != (char *)NULL) && (*name == '-')) || level0)
- X! {
- X! talking++;
- X
- X- if ((f = O_for_execute ("/etc/profile")) >= 0)
- X- next (remap(f));
- X-
- X- if ((f = O_for_execute ("profile")) >= 0)
- X- next (remap(f));
- X- }
- X-
- X /* Set up signals */
- X
- X if (talking)
- X--- 250,257 ----
- X /* Read profile ? */
- X
- X if (((name != (char *)NULL) && (*name == '-')) || level0)
- X! Load_profiles ();
- X
- X /* Set up signals */
- X
- X if (talking)
- X***************
- X*** 332,340 ****
- X--- 286,296 ----
- X {
- X if (talking && e.iop <= iostack)
- X {
- X+ In_Col_Zero ();
- X Check_Mail ();
- X put_prompt (ps1->value);
- X r_flag = l_rflag;
- X+ closeall (); /* Clean up any open shell files */
- X }
- X
- X onecommand ();
- X***************
- X*** 366,374 ****
- X {
- X register int i;
- X jmp_buf m1;
- X! C_Op *outtree;
- X
- X-
- X /* Exit any previous environments */
- X
- X while (e.oenv)
- X--- 322,329 ----
- X {
- X register int i;
- X jmp_buf m1;
- X! C_Op *outtree = (C_Op *)NULL;
- X
- X /* Exit any previous environments */
- X
- X while (e.oenv)
- X***************
- X*** 397,404 ****
- X SW_intr)
- X {
- X
- X! /* Failed - clean up */
- X
- X while (e.oenv)
- X quitenv ();
- X
- X--- 352,371 ----
- X SW_intr)
- X {
- X
- X! /* Failed - If parse failed - save command line as history */
- X
- X+ #ifndef NO_HISTORY
- X+ if ((outtree == (C_Op *)NULL) && Interactive ())
- X+ Add_History (FALSE);
- X+ #endif
- X+
- X+ /* If interrupt occured, remove current Input stream */
- X+
- X+ if (SW_intr && (e.iop > e.iobase))
- X+ e.iop--;
- X+
- X+ /* Quit all environments */
- X+
- X while (e.oenv)
- X quitenv ();
- X
- X***************
- X*** 436,456 ****
- X
- X /* Save the environment information */
- X
- X! if (talking && e.iop <= iostack)
- X Add_History (FALSE);
- X
- X! if (!FL_TEST ('n'))
- X! execute (outtree, NOPIPE, NOPIPE, 0);
- X
- X /* Make sure the I/O and environment are back at level 0 and then clear them */
- X
- X Execute_stack_depth = 0;
- X
- X if (NSubShells != 0)
- X Delete_G_VL ();
- X
- X if (NSave_IO_E)
- X! restore_std (0);
- X
- X if (MSubShells)
- X DELETE (SubShells);
- X--- 403,428 ----
- X
- X /* Save the environment information */
- X
- X! #ifndef NO_HISTORY
- X! if (Interactive ())
- X Add_History (FALSE);
- X+ #endif
- X
- X! /* Ok - if we wail, we need to clean up the stacks */
- X
- X+ if ((setjmp (failpt = m1) == 0) && !FL_TEST ('n'))
- X+ execute (outtree, NOPIPE, NOPIPE, 0);
- X+
- X /* Make sure the I/O and environment are back at level 0 and then clear them */
- X
- X Execute_stack_depth = 0;
- X+ Clear_Extended_File ();
- X
- X if (NSubShells != 0)
- X Delete_G_VL ();
- X
- X if (NSave_IO_E)
- X! restore_std (0, TRUE);
- X
- X if (MSubShells)
- X DELETE (SubShells);
- X***************
- X*** 495,502 ****
- X if (execflg)
- X fail ();
- X
- X! /* Clean up */
- X
- X scraphere ();
- X freehere (1);
- X
- X--- 467,480 ----
- X if (execflg)
- X fail ();
- X
- X! if (Orig_I24_V == (void (far *)())NULL)
- X! {
- X! S_puts ("sh: ignoring attempt to leave lowest level shell\n");
- X! fail ();
- X! }
- X
- X+ /* Clean up */
- X+
- X scraphere ();
- X freehere (1);
- X
- X***************
- X*** 506,513 ****
- X--- 484,493 ----
- X
- X /* Dump history on exit */
- X
- X+ #ifndef NO_HISTORY
- X if (talking && isatty(0))
- X Dump_History ();
- X+ #endif
- X
- X closeall ();
- X exit (exstat);
- X***************
- X*** 608,614 ****
- X }
- X
- X *ep = e;
- X! e.oenv = ep;
- X e.errpt = errpt;
- X return FALSE;
- X }
- X--- 588,595 ----
- X }
- X
- X *ep = e;
- X! e.eof_p = FALSE; /* Disable EOF processing */
- X! e.oenv = ep;
- X e.errpt = errpt;
- X return FALSE;
- X }
- X***************
- X*** 669,684 ****
- X }
- X
- X /*
- X- * Add a file to the input stack
- X- */
- X-
- X- void next (f)
- X- int f;
- X- {
- X- PUSHIO (afile, f, filechar);
- X- }
- X-
- X- /*
- X * SIGINT interrupt processing
- X */
- X
- X--- 650,655 ----
- X***************
- X*** 696,707 ****
- X if (talking)
- X {
- X if (inparse)
- X- {
- X S_putc (NL);
- X- fail ();
- X- }
- X- }
- X
- X /* No - exit */
- X
- X else
- X--- 667,679 ----
- X if (talking)
- X {
- X if (inparse)
- X S_putc (NL);
- X
- X+ /* Abandon processing */
- X+
- X+ fail ();
- X+ }
- X+
- X /* No - exit */
- X
- X else
- X***************
- X*** 751,756 ****
- X--- 723,731 ----
- X void sig (i)
- X register int i;
- X {
- X+ if (i == SIGINT) /* Need this because swapper sets it */
- X+ SW_intr = 0;
- X+
- X trapset = i;
- X signal (i, sig);
- X }
- X***************
- X*** 778,784 ****
- X unset (tval, TRUE);
- X }
- X
- X! RUN (aword, trapstr, nlchar);
- X }
- X
- X /*
- X--- 753,759 ----
- X unset (tval, TRUE);
- X }
- X
- X! RUN (aword, trapstr, nlchar, TRUE);
- X }
- X
- X /*
- X***************
- X*** 858,864 ****
- X * give variable at `vp' the value `val'.
- X */
- X
- X! void setval(vp, val)
- X Var_List *vp;
- X char *val;
- X {
- X--- 833,839 ----
- X * give variable at `vp' the value `val'.
- X */
- X
- X! void setval (vp, val)
- X Var_List *vp;
- X char *val;
- X {
- X***************
- X*** 911,917 ****
- X
- X /* Check for $PATH reset in restricted shell */
- X
- X! if (!disable && (strcmp (vp->name, Path) == 0) && check_rsh (Path))
- X return;
- X
- X /* Get space for string ? */
- X--- 886,892 ----
- X
- X /* Check for $PATH reset in restricted shell */
- X
- X! if (!disable && (strncmp (vp->name, "PATH=", 5) == 0) && check_rsh (Path))
- X return;
- X
- X /* Get space for string ? */
- X***************
- X*** 941,948 ****
- X
- X if (FL_TEST ('a'))
- X s_vstatus (vp, EXPORT);
- X- }
- X
- X /*
- X * Set the status of an environment variable
- X */
- X--- 916,928 ----
- X
- X if (FL_TEST ('a'))
- X s_vstatus (vp, EXPORT);
- X
- X+ /* Convert UNIX to DOS for PATH variable */
- X+
- X+ if (vp == path)
- X+ U2D_Path ();
- X+ }
- X+
- X /*
- X * Set the status of an environment variable
- X */
- X***************
- X*** 1425,1437 ****
- X *s = tolower(*s);
- X
- X if (*s == '%')
- X! S_putc ('%');
- X
- X else
- X {
- X *buf = 0;
- X
- X! switch (*s)
- X {
- X case 'e': /* Current event number */
- X if (History_Enabled)
- X--- 1405,1417 ----
- X *s = tolower(*s);
- X
- X if (*s == '%')
- X! v1_putc ('%');
- X
- X else
- X {
- X *buf = 0;
- X
- X! switch (*(s++))
- X {
- X case 'e': /* Current event number */
- X if (History_Enabled)
- X***************
- X*** 1453,1459 ****
- X case 'n': /* default drive */
- X strcpy (buf, C_dir->value);
- X
- X! if (*s == 'n')
- X buf[1] = 0;
- X
- X break;
- X--- 1433,1439 ----
- X case 'n': /* default drive */
- X strcpy (buf, C_dir->value);
- X
- X! if (*(s - 1) == 'n')
- X buf[1] = 0;
- X
- X break;
- X***************
- X*** 1465,1471 ****
- X
- X /* Output the string */
- X
- X! S_puts (buf);
- X }
- X }
- X
- X--- 1445,1451 ----
- X
- X /* Output the string */
- X
- X! v1_puts (buf);
- X }
- X }
- X
- X***************
- X*** 1473,1490 ****
- X
- X else if (*s == '\\')
- X {
- X if ((i = Process_Escape (&s)) == -1)
- X i = 0;
- X
- X! S_putc (i);
- X }
- X
- X else
- X! S_putc (*s);
- X!
- X! /* Go to the next character */
- X!
- X! s++;
- X }
- X }
- X
- X--- 1453,1467 ----
- X
- X else if (*s == '\\')
- X {
- X+ ++s;
- X if ((i = Process_Escape (&s)) == -1)
- X i = 0;
- X
- X! v1_putc ((char)i);
- X }
- X
- X else
- X! v1_putc (*(s++));
- X }
- X }
- X
- X***************
- X*** 1496,1544 ****
- X void Getcwd ()
- X {
- X char ldir[PATH_MAX + 6];
- X- char *cp = getcwd (ldir, PATH_MAX + 4);
- X
- X! strlwr (cp);
- X
- X /* Convert to Unix format */
- X
- X! while (*cp)
- X! {
- X! if (*cp == '\\')
- X! *cp = '/';
- X
- X- ++cp;
- X- }
- X-
- X /* Save in environment */
- X
- X setval ((C_dir = lookup ("~", TRUE)), ldir);
- X }
- X
- X /*
- X! * Patch up various parts of the system for the shell. At the moment, we
- X! * modify the ctype table so that _ is an upper case character.
- X */
- X
- X! static void patch_up ()
- X {
- X! /* Patch the ctype table as a cheat */
- X
- X (_ctype+1)['_'] |= _UPPER;
- X
- X! /* Save the interrupt 24 address */
- X
- X! SW_I24_V = _dos_getvect (0x24);
- X!
- X! /* Set the newinterrupt 24 address */
- X!
- X _dos_setvect (0x24, SW_Int24);
- X- }
- X
- X /*
- X * Mail Check processing. Every $MAILCHECK seconds, we check either $MAIL
- X * or $MAILPATH to see if any file has changed its modification time since
- X! * we last looked. In $MAILCHECK, the files are separated by colons (:).
- X * If the filename contains a %, the string following the % is the message
- X * to display if the file has changed.
- X */
- X--- 1473,1625 ----
- X void Getcwd ()
- X {
- X char ldir[PATH_MAX + 6];
- X
- X! getcwd (ldir, PATH_MAX + 4);
- X! ldir[PATH_MAX + 5] = 0;
- X
- X /* Convert to Unix format */
- X
- X! Convert_Backslashes (strlwr (ldir));
- X
- X /* Save in environment */
- X
- X setval ((C_dir = lookup ("~", TRUE)), ldir);
- X }
- X
- X /*
- X! * Initialise the shell and Patch up various parts of the system for the
- X! * shell. At the moment, we modify the ctype table so that _ is an upper
- X! * case character.
- X */
- X
- X! static bool Initialise (name)
- X! char *name;
- X {
- X! register char *s, *s1;
- X! char **ap;
- X! Var_List *lset;
- X! bool l_rflag = FALSE;
- X
- X+ /* Patch the ctype table as a cheat */
- X+
- X (_ctype+1)['_'] |= _UPPER;
- X
- X! /* Get original interrupt 24 address and set up our new interrupt 24
- X! * address
- X! */
- X
- X! Orig_I24_V = _dos_getvect (0x24);
- X _dos_setvect (0x24, SW_Int24);
- X
- X+ /* Load the environment into our structures */
- X+
- X+ if ((ap = environ) != (char **)NULL)
- X+ {
- X+ while (*ap)
- X+ assign (*ap++, !COPYV);
- X+
- X+ for (ap = environ; *ap;)
- X+ s_vstatus (lookup (*ap++, TRUE), EXPORT);
- X+ }
- X+
- X+ /* Change COMSPEC to unix format for execution */
- X+
- X+ lset = lookup ("COMSPEC", FALSE);
- X+ Convert_Backslashes (lset->value);
- X+ s_vstatus (lset, C_MSDOS);
- X+
- X+ /* Zap all files */
- X+
- X+ closeall ();
- X+ areanum = 1;
- X+
- X+ /* Get the current directory */
- X+
- X+ Getcwd ();
- X+
- X+ /* Set up SHELL variable. First check for a restricted shell. Check the
- X+ * restricted shell
- X+ */
- X+
- X+ Program_Name = name;
- X+ if ((s = strrchr (name, '/')) == (char *)NULL)
- X+ s = name;
- X+
- X+ if ((s1 = strchr (s, '.')) != (char *)NULL)
- X+ *s1 = 0;
- X+
- X+ if (strcmp (s, "rsh") == 0)
- X+ l_rflag = TRUE;
- X+
- X+ /* Has the program name got a .exe extension - Yes probably DOS 3+. So
- X+ * save it as the Shell name
- X+ */
- X+
- X+ lset = lookup (shell, TRUE);
- X+
- X+ if (s1 != (char *)NULL)
- X+ {
- X+ if ((stricmp (s1 + 1, "exe") == 0) && (lset->value == null))
- X+ setval (lset, name);
- X+
- X+ *s1 = '.';
- X+ }
- X+
- X+ /* Default if necessary */
- X+
- X+ if (lset->value == null)
- X+ setval (lset, shellname);
- X+
- X+ Convert_Backslashes (lset->value);
- X+ s_vstatus (lset, EXPORT);
- X+
- X+ /* Check for restricted shell */
- X+
- X+ if ((s = strrchr (lset->value, '/')) == (char *)NULL)
- X+ s = lset->value;
- X+
- X+ else
- X+ s++;
- X+
- X+ if (*s == 'r')
- X+ l_rflag = TRUE;
- X+
- X+ /* Set up home directory */
- X+
- X+ if ((lset = lookup (home, TRUE))->value == null)
- X+ setval (lset, C_dir->value);
- X+
- X+ s_vstatus (lset, EXPORT);
- X+
- X+ /* Set up history file location */
- X+
- X+ setval (lookup ("$", TRUE), putn (getpid ()));
- X+
- X+ Load_G_VL ();
- X+ path->status |= (EXPORT | PONLY);
- X+ ifs->status |= (EXPORT | PONLY);
- X+ ps1->status |= (EXPORT | PONLY);
- X+ ps2->status |= (EXPORT | PONLY);
- X+
- X+ if (path->value == null)
- X+ setval (path, search);
- X+
- X+ if (ifs->value == null)
- X+ setval (ifs, " \t\n");
- X+
- X+ if (ps1->value == null)
- X+ setval (ps1, "$ ");
- X+
- X+ if (ps2->value == null)
- X+ setval (ps2, "> ");
- X+
- X+ return l_rflag;
- X+ }
- X+
- X /*
- X * Mail Check processing. Every $MAILCHECK seconds, we check either $MAIL
- X * or $MAILPATH to see if any file has changed its modification time since
- X! * we last looked. In $MAILCHECK, the files are separated by semi-colon (;).
- X * If the filename contains a %, the string following the % is the message
- X * to display if the file has changed.
- X */
- X***************
- X*** 1571,1577 ****
- X
- X /* Look for the next separator */
- X
- X! while ((cp = strchr (sp, ':')) != (char *)NULL)
- X {
- X *cp = 0;
- X
- X--- 1652,1658 ----
- X
- X /* Look for the next separator */
- X
- X! while ((cp = strchr (sp, ';')) != (char *)NULL)
- X {
- X *cp = 0;
- X
- X***************
- X*** 1599,1607 ****
- X if (ap != (char *)NULL)
- X *ap = '%';
- X
- X! /* Restore the colon and find the next one */
- X
- X! *cp = ':';
- X sp = cp + 1;
- X }
- X }
- X--- 1680,1688 ----
- X if (ap != (char *)NULL)
- X *ap = '%';
- X
- X! /* Restore the semi-colon and find the next one */
- X
- X! *cp = ';';
- X sp = cp + 1;
- X }
- X }
- X***************
- X*** 1674,1677 ****
- X--- 1755,1866 ----
- X return;
- X }
- X }
- X+ }
- X+
- X+ /*
- X+ * Convert backslashes to slashes for UNIX
- X+ */
- X+
- X+ static void Convert_Backslashes (sp)
- X+ char *sp;
- X+ {
- X+ while (*sp)
- X+ {
- X+ if (*sp == '\\')
- X+ *sp = '/';
- X+
- X+ ++sp;
- X+ }
- X+ }
- X+
- X+ /* Load profiles onto I/O Stack */
- X+
- X+ static void Load_profiles ()
- X+ {
- X+ char *name;
- X+ int f;
- X+
- X+ /* Set up home profile */
- X+
- X+ name = Build_H_Filename ("profile");
- X+
- X+ talking = TRUE;
- X+
- X+ if ((f = O_for_execute (name, (char **)NULL, (int *)NULL)) >= 0)
- X+ {
- X+ PUSHIO (afile, remap (f), filechar);
- X+ }
- X+
- X+ DELETE (name);
- X+
- X+ if ((f = O_for_execute ("/etc/profile", (char **)NULL, (int *)NULL)) >= 0)
- X+ {
- X+ PUSHIO (afile, remap (f), filechar);
- X+ }
- X+ }
- X+
- X+ /*
- X+ * Convert Unix PATH to MSDOS PATH
- X+ */
- X+
- X+ static void U2D_Path ()
- X+ {
- X+ char *cp = path->value;
- X+ int colon = 0;
- X+
- X+ /* If there is a semi-colon or a backslash, we assume this is a DOS format
- X+ * path
- X+ */
- X+
- X+ if ((strchr (cp, ';') != (char *)NULL) ||
- X+ (strchr (cp, '\\') != (char *)NULL))
- X+ return;
- X+
- X+ /* Count the number of colons */
- X+
- X+ while ((cp = strchr (cp, ':')) != (char *)NULL)
- X+ {
- X+ ++colon;
- X+ ++cp;
- X+ }
- X+
- X+ /* If there are no colons or there is one colon as the second character, it
- X+ * is probably an MSDOS path
- X+ */
- X+
- X+ cp = path->value;
- X+ if ((colon == 0) || ((colon == 1) && (*(cp + 1) == ':')))
- X+ return;
- X+
- X+ /* Otherwise, convert all colons to semis */
- X+
- X+ while ((cp = strchr (cp, ':')) != (char *)NULL)
- X+ *(cp++) = ';';
- X+ }
- X+
- X+ /* Generate a file name from a directory and name. Return null if an error
- X+ * occurs or some malloced space containing the file name otherwise
- X+ */
- X+
- X+ char *Build_H_Filename (name)
- X+ char *name;
- X+ {
- X+ char *dir = lookup (home, FALSE)->value;
- X+ char *cp;
- X+
- X+ /* Get some space */
- X+
- X+ if ((cp = getcell (strlen (dir) + strlen (name) + 2)) == (char *)NULL)
- X+ return null;
- X+
- X+ /* Addend the directory and a / if the directory does not end in one */
- X+
- X+ strcpy (cp, dir);
- X+
- X+ if (cp[strlen (cp) - 1] != '/')
- X+ strcat (cp, "/");
- X+
- X+ /* Append the file name */
- X+
- X+ return strcat (cp, name);
- X }
- XIndex: Install
- XPrereq: 1.1
- X*** ../sh15/Install Fri Mar 2 11:25:07 1990
- X--- Install Fri Apr 6 17:57:25 1990
- X***************
- X*** 1,4 ****
- X! MS-DOS Shell Version 1.4 INSTALL January 1990
- X
- X MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
- X
- X--- 1,4 ----
- X! MS-DOS Shell Version 1.6 INSTALL April 1990
- X
- X MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
- X
- X***************
- X*** 13,24 ****
- X 2. The sources (or parts thereof) or objects generated from the
- X sources (or parts of sources) cannot be sold under any circumstances.
- X
- X! $Header: install 1.1 90/01/29 18:03:04 MS_user Exp $
- X
- X $Log: install $
- X! # Revision 1.1 90/01/29 18:03:04 MS_user
- X! # Initial revision
- X! #
- X ________________________________________________________________________________
- X
- X To rebuild and install the shell, you should follow the following the
- X--- 13,27 ----
- X 2. The sources (or parts thereof) or objects generated from the
- X sources (or parts of sources) cannot be sold under any circumstances.
- X
- X! $Header: install 1.2 90/04/03 18:03:28 MS_user Exp $
- X
- X $Log: install $
- X! Revision 1.2 90/04/03 18:03:28 MS_user
- X! Upgrade for 1.6
- X!
- X! Revision 1.1 90/01/29 18:03:04 MS_user
- X! Initial revision
- X!
- X ________________________________________________________________________________
- X
- X To rebuild and install the shell, you should follow the following the
- X***************
- X*** 42,48 ****
- X the bottom three bits, noted the bytes around this location,
- X extracted the open function from the library, patched the mask
- X to be 0x83 instead of 0x03, and then replaced the function in the
- X! library.
- X
- X 3) Compile the library files in the directory /lib in large model mode
- X and add the objects to your large model library
- X--- 45,51 ----
- X the bottom three bits, noted the bytes around this location,
- X extracted the open function from the library, patched the mask
- X to be 0x83 instead of 0x03, and then replaced the function in the
- X! library (Also see the Patch.Lib file).
- X
- X 3) Compile the library files in the directory /lib in large model mode
- X and add the objects to your large model library
- X***************
- X*** 61,67 ****
- X
- X Install the shell in its correct location.
- X
- X! 5) Modify the scripts as appropriate for your installation and install
- X! them in the correct directories.
- X
- X! 6) Type "sh -0" and see what happens.
- X--- 64,72 ----
- X
- X Install the shell in its correct location.
- X
- X! 5) Modify the initialisation file sh.ini for your edit key preferences.
- X
- X! 6) Modify the scripts as appropriate for your installation and install
- X! them in the correct directories.
- X!
- X! 7) Type "sh -0" and see what happens.
- XIndex: MANIFEST
- X*** ../sh15/MANIFEST Fri Mar 9 13:52:35 1990
- X--- MANIFEST Thu Mar 15 09:35:19 1990
- X***************
- X*** 1,8 ****
- X Install | Installation instructions
- X MANIFEST | This list
- X! Notes | Some addition notes for release
- X ReadMe | The Release Readme
- X sh.1 | The Manual page in *roff format
- X include/Changes | Changes to standard include files
- X include/dirent.h | Directory (3) functions include
- X include/unistd.h | unistd for MSDOS
- X--- 1,12 ----
- X Install | Installation instructions
- X MANIFEST | This list
- X! Notes1.4 | Some addition notes for release 1.4
- X! Notes1.5 | Some addition notes for release 1.5
- X! Notes1.6 | Some addition notes for release 1.6
- X ReadMe | The Release Readme
- X sh.1 | The Manual page in *roff format
- X+ ms_dio.2 | The Manual page for ms_dio.c in *roff format
- X+ Patch.Lib | Instructions for patching open.obj for O_NOINHERIT
- X include/Changes | Changes to standard include files
- X include/dirent.h | Directory (3) functions include
- X include/unistd.h | unistd for MSDOS
- X***************
- X*** 13,24 ****
- X lib/director.c | POSIX directory (3) functions for MSDOS
- X lib/popen.c | popen/pclose for MSDOS
- X lib/syserr.c | Modified sys_errlist for MSDOS
- X! lib/stdargv.c | Replacement command list processing for programes
- X lib/pnmatch.c | Pattern matching function
- X lib/getopt.c | getopt function
- X scripts/l | A sample shell script
- X scripts/extend.lst | A sample extended command line processing list
- X scripts/profile.sh | A sample start up shell script
- X shell/Makefile | Shell - makefile
- X shell/sh0.asm | Shell - Swap functions
- X shell/sh1.c | Shell - Main program and memory control functions
- X--- 17,29 ----
- X lib/director.c | POSIX directory (3) functions for MSDOS
- X lib/popen.c | popen/pclose for MSDOS
- X lib/syserr.c | Modified sys_errlist for MSDOS
- X! lib/stdargv.c | Replacement command list processing for programme
- X lib/pnmatch.c | Pattern matching function
- X lib/getopt.c | getopt function
- X scripts/l | A sample shell script
- X scripts/extend.lst | A sample extended command line processing list
- X scripts/profile.sh | A sample start up shell script
- X+ scripts/sh.ini | A sample shell initialisation file
- X shell/Makefile | Shell - makefile
- X shell/sh0.asm | Shell - Swap functions
- X shell/sh1.c | Shell - Main program and memory control functions
- XIndex: ReadMe
- XPrereq: 1.3
- X*** ../sh15/ReadMe Wed Mar 7 11:08:34 1990
- X--- ReadMe Fri Apr 6 17:58:18 1990
- X***************
- X*** 1,4 ****
- X! MS-DOS Shell Version 1.5 README February 1990
- X
- X MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
- X
- X--- 1,4 ----
- X! MS-DOS Shell Version 1.6 README April 1990
- X
- X MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
- SHAR_EOF
- echo "End of part 6"
- echo "File Patch1.6 is continued in part 7"
- echo "7" > s2_seq_.tmp
- exit 0
-
-
-