tcsh with a command line editor (1 of 5)

Paul Placeway paul at osu-dbs.UUCP
Sat Apr 14 05:25:34 AEST 1984


.
The following code is my changes to Ken Greer's tcsh.  I have added a visual
mini-editor to the shell, and cleaned up the expansion routines some what.
note that this is the 4.1 version.  When we get 4.2 up I'll repost the new
changes.

Please send any changes back to me so that I can update our version.

Note: this is part 1 of 5, you need all of the parts to make tcsh.

					Paul W. Placeway
					The Ohio State University IRCC
					(UUCP: cbosgd!osu-dbs!paul)
					(CSNet: paul at ohio-state)

================ cut here ================
: This is a shar archive.  Extract with sh, not csh.
echo x - INSTALL
cat > INSTALL << '!Funky!Stuff!'
Installing the new T-C shell...

1. Make a new directory and copy the original csh sources to it.

2. Copy these sources to that directory.

3. The file "DIFFS" is a list of differences between the orignal csh and the
   same files in tcsh.  Go through the file, making the changes to the files.

4. make

5. Move ./tcsh wherever you like.

6. Enjoy.

Note:
   The files dir.h and dir14.c support the old 14 character UNIX
   directories.  Change the makefile if you have the Berkeley arbitrary
   length file names.

   Any references to /u0/osu should be changed to whatever your local
   software directory is.

See tcsh.1 (man file) for changes made.

If you make any fixes or changes, please mail them back to

					Paul W. Placeway
					The Ohio State University IRCC
					(UUCP: cbosgd!osu-dbs!paul)
					(CSNet: paul at ohio-state)

!Funky!Stuff!
echo x - DIFFS
cat > DIFFS << '!Funky!Stuff!'
========	diff -bc csh/sh.c tcsh/sh.c	========

*** csh/sh.c	Fri Apr 13 10:43:58 1984
--- tcsh/sh.c	Fri Apr 13 10:45:00 1984
***************
*** 12,18
   * April 1980
   */
  
! char	*pathlist[] =	{ ".", "/usr/ucb", "/bin", "/usr/bin", 0 };
  char	HIST = '!';
  char	HISTSUB = '^';
  bool	nofile;

--- 12,20 -----
   * April 1980
   */
  
! #define AUTOLOGOUT      "60"            /* 1 Hour alarm */
! char    *pathlist[] =   { ".", "/u0/osu/bin", "/usr/ucb", "/bin",
! 			  "/usr/bin", "/u0/local/bin", 0 };
  char    HIST = '!';
  char    HISTSUB = '^';
  bool    nofile;
***************
*** 23,28
  bool	fast;
  bool	prompt = 1;
  
  main(c, av)
  	int c;
  	char **av;

--- 25,38 -----
  bool    fast;
  bool    prompt = 1;
  
+ auto_logout ()
+ {
+     printf("auto-logout\n");
+     close(SHIN);
+     child++;
+     goodbye();
+ }
+ 
  main(c, av)
          int c;
          char **av;
***************
*** 54,59
  	 */
  
  	set("status", "0");
  	dinit(cp = getenv("HOME"));	/* dinit thinks that HOME == cwd in a
  					 * login shell */
  	if (cp == NOSTR)

--- 64,72 -----
           */
  
          set("status", "0");
+ 	set("tcsh", "1");
+         set("autologout", AUTOLOGOUT);
+         sigset (SIGALRM, auto_logout);
          dinit(cp = getenv("HOME"));     /* dinit thinks that HOME == cwd in a
                                           * login shell */
          if (cp == NOSTR)
***************
*** 69,74
  	if ((cp = getenv("TERM")) != NOSTR)
  		set("term", savestr(cp));
  	/*
  	 * Re-initialize path if set in environment
  	 */
  	if ((cp = getenv("PATH")) == NOSTR)

--- 82,99 -----
          if ((cp = getenv("TERM")) != NOSTR)
                  set("term", savestr(cp));
  	/*
+ 	 * set the shell-level var to 1 or increment it.
+ 	 */
+         if ((cp = getenv("SHLVL")) != NOSTR) {
+ 		char buff[128];
+ 		itoa (1 + atoi (cp), buff);
+                 set("shlvl", savestr (buff));
+ 		setenv ("SHLVL", buff);
+ 	} else {
+ 		set("shlvl", savestr("1"));
+ 		setenv ("SHLVL", "1");
+ 	}
+         /*
           * Re-initialize path if set in environment
           */
          if ((cp = getenv("PATH")) == NOSTR)
***************
*** 95,100
  		pv[i] = 0;
  		set1("path", pv, &shvhed);
  	}
  	set("shell", SHELLPATH);
  
  	doldol = putn(getpid());		/* For $$ */

--- 120,126 -----
                  pv[i] = 0;
                  set1("path", pv, &shvhed);
          }
+ 
          set("shell", SHELLPATH);
  
          doldol = putn(getpid());                /* For $$ */
***************
*** 236,243
  	/*
  	 * Set up the prompt.
  	 */
! 	if (prompt)
! 		set("prompt", uid == 0 ? "# " : "% ");
  
  	/*
  	 * If we are an interactive shell, then start fiddling

--- 262,270 -----
          /*
           * Set up the prompt.
           */
!         if (prompt) {
!                 set("prompt", uid == 0 ? "} " : "> ");
! 	}
  
          /*
           * If we are an interactive shell, then start fiddling
***************
*** 312,317
  	haderr = 0;		/* In case second time through */
  	if (!fast && reenter == 0) {
  		reenter++;
  		/* Will have value("home") here because set fast if don't */
  		srccat(value("home"), "/.cshrc");
  		if (!fast && !arginp && !onelflg)

--- 339,349 -----
          haderr = 0;             /* In case second time through */
          if (!fast && reenter == 0) {
                  reenter++;
+                 if (!fast && !arginp && !onelflg) {
+ 		    tw_init_bindings();
+ 		    ilsetup(SHIN, SHOUT);
+ 	    		/* setup the editor BEFORE doing .tcshrc */
+ 		}    
                  /* Will have value("home") here because set fast if don't */
                  srccat(value("home"), "/.tcshrc");
                  if (!fast && !arginp && !onelflg) {
***************
*** 313,320
  	if (!fast && reenter == 0) {
  		reenter++;
  		/* Will have value("home") here because set fast if don't */
! 		srccat(value("home"), "/.cshrc");
! 		if (!fast && !arginp && !onelflg)
  			dohash();
  		if (loginsh) {
  			int ldisc;

--- 345,352 -----
  	    		/* setup the editor BEFORE doing .tcshrc */
  		}    
                  /* Will have value("home") here because set fast if don't */
!                 srccat(value("home"), "/.tcshrc");
!                 if (!fast && !arginp && !onelflg) {
                          dohash();
  		}		/* setup the command compleation path */
                  if (loginsh) {
***************
*** 316,321
  		srccat(value("home"), "/.cshrc");
  		if (!fast && !arginp && !onelflg)
  			dohash();
  		if (loginsh) {
  			int ldisc;
  			srccat(value("home"), "/.login");

--- 348,354 -----
                  srccat(value("home"), "/.tcshrc");
                  if (!fast && !arginp && !onelflg) {
                          dohash();
+ 		}		/* setup the command compleation path */
                  if (loginsh) {
                          int ldisc;
                          srccat(value("home"), "/.login");
***************
*** 414,419
  #ifdef INGRES
  	srcunit(unit, 0);
  #else
  	srcunit(unit, 1);
  #endif
  }

--- 447,455 -----
  #ifdef INGRES
          srcunit(unit, 0);
  #else
+ #ifdef OSU
+         srcunit(unit, 0);
+ #else
          srcunit(unit, 1);
  #endif
  #endif
***************
*** 416,421
  #else
  	srcunit(unit, 1);
  #endif
  }
  
  /*

--- 452,458 -----
  #else
          srcunit(unit, 1);
  #endif
+ #endif
  }
  
  /*
***************
*** 420,426
  
  /*
   * Source to a unit.  If onlyown it must be our file or our group or
!  * we don't chance it.	This occurs on ".cshrc"s and the like.
   */
  srcunit(unit, onlyown)
  	register int unit;

--- 457,463 -----
  
  /*
   * Source to a unit.  If onlyown it must be our file or our group or
!  * we don't chance it.  This occurs on ".tcshrc"s and the like.
   */
  srcunit(unit, onlyown)
          register int unit;
***************
*** 623,629
  	getexit(osetexit);
  	for (;;) {
  		pendjob();
! 		paraml.next = paraml.prev = ¶ml;
  		paraml.word = "";
  		t = 0;
  		setexit();

--- 660,666 -----
          getexit(osetexit);
          for (;;) {
                  pendjob();
!                 paraml.next = paraml .prev = ¶ml;
                  paraml.word = "";
                  t = 0;
                  setexit();
***************
*** 677,697
  			 * need or want to prompt.
  			 */
  			if (fseekp == feobp)
! 				if (!whyles)
! 					for (cp = value("prompt"); *cp; cp++)
! 						if (*cp == HIST)
! 							printf("%d", eventno + 1);
! 						else {
! 							if (*cp == '\\' && cp[1] == HIST)
! 								cp++;
! 							putchar(*cp | QUOTE);
! 						}
! 				else
! 					/*
! 					 * Prompt for forward reading loop
! 					 * body content.
! 					 */
! 					printf("? ");
  			flush();
  		}
  		err = 0;

--- 714,720 -----
                           * need or want to prompt.
                           */
                          if (fseekp == feobp)
!                                 printprompt ();
                          flush();
                          if (cp = value("autologout"))
                              alarm (atoi(cp) * 60);
***************
*** 693,698
  					 */
  					printf("? ");
  			flush();
  		}
  		err = 0;
  

--- 716,723 -----
                          if (fseekp == feobp)
                                  printprompt ();
                          flush();
+                         if (cp = value("autologout"))
+                             alarm (atoi(cp) * 60);
                  }
                  err = 0;
  
***************
*** 705,710
  			prlex(&paraml);
  			haderr = 0;
  		}
  
  		/*
  		 * The parser may lose space if interrupted.

--- 730,736 -----
                          prlex(&paraml);
                          haderr = 0;
                  }
+                 alarm (0);                      /* Turn auto-logout off */
  
                  /*
                   * The parser may lose space if interrupted.
***************
*** 859,862
  #else
  	_exit(i);
  #endif
  }

--- 885,917 -----
  #else
          _exit(i);
  #endif
+ }
+ 
+ printprompt ()
+ {
+     register char *cp;
+     extern char *value ();
+     char buff[128];
+     PromptBuf[0] = '\0';
+     if (!whyles) {
+             for (cp = value("prompt"); *cp; cp++) {
+                     if (*cp == HIST) {
+                             itoa(eventno + 1, buff);
+ 			    strcat(PromptBuf, buff);
+ 		    }
+                     else {
+                             if (*cp == '\\' && cp[1] == HIST) {
+                                     cp++;
+ 			    }
+                             strncat(PromptBuf, cp, 1);
+                     }
+ 	    }
+     }
+     else {
+             /*
+              * Prompt for forward reading loop
+              * body content.
+              */
+ 	    strncat(PromptBuf, "? ", 2);
+     }
  }

========	diff -bc csh/sh.exec.c tcsh/sh.exec.c	========

*** csh/sh.exec.c	Fri Apr 13 10:44:01 1984
--- tcsh/sh.exec.c	Fri Apr 13 10:45:04 1984
***************
*** 252,257
  	struct stat stb;
  	struct direct dirbuf[BUFSIZ / sizeof (struct direct)];
  	char d_name[DIRSIZ + 1];
  	register int dirf, cnt;
  	int i = 0;
  	struct varent *v = adrof("path");

--- 252,258 -----
  	struct stat stb;
  	struct direct dirbuf[BUFSIZ / sizeof (struct direct)];
  	char d_name[DIRSIZ + 1];
+ 	char fnamebuf[BUFSIZ];
  	register int dirf, cnt;
  	int i = 0;
  	struct varent *v = adrof("path");
***************
*** 257,262
  	struct varent *v = adrof("path");
  	char **pv;
  
  	havhash = 1;
  	for (cnt = 0; cnt < HSHSIZ; cnt++)
  		xhash[cnt] = 0;

--- 258,264 -----
  	struct varent *v = adrof("path");
  	char **pv;
  
+ 	tw_clear_comm_list();
  	havhash = 1;
  	for (cnt = 0; cnt < HSHSIZ; cnt++)
  		xhash[cnt] = 0;
***************
*** 272,278
  			close(dirf);
  			continue;
  		}
! 		while ((cnt = read(dirf, (char *) dirbuf, sizeof dirbuf)) >= sizeof dirbuf[0]) {
  			register struct direct *ep = dirbuf;
  
  			for (cnt /= sizeof(struct direct); cnt > 0; cnt--, ep++) {

--- 274,282 -----
  			close(dirf);
  			continue;
  		}
! 				/* put check for non-exes here */
! 		while ((cnt = read(dirf, (char *) dirbuf, 
! 		    sizeof dirbuf)) >= sizeof dirbuf[0]) {
  			register struct direct *ep = dirbuf;
  
  			for (cnt /= sizeof(struct direct); 
***************
*** 275,281
  		while ((cnt = read(dirf, (char *) dirbuf, sizeof dirbuf)) >= sizeof dirbuf[0]) {
  			register struct direct *ep = dirbuf;
  
! 			for (cnt /= sizeof(struct direct); cnt > 0; cnt--, ep++) {
  				if (ep->d_ino == 0)
  					continue;
  				copdent(d_name, ep->d_name);

--- 279,286 -----
  		    sizeof dirbuf)) >= sizeof dirbuf[0]) {
  			register struct direct *ep = dirbuf;
  
! 			for (cnt /= sizeof(struct direct); 
! 			    cnt > 0; cnt--, ep++) {
  				if (ep->d_ino == 0)
  					continue;
  				copdent(d_name, ep->d_name);
***************
*** 279,284
  				if (ep->d_ino == 0)
  					continue;
  				copdent(d_name, ep->d_name);
  				xhash[hash(d_name)] |= (1 << i);
  			}
  		}

--- 284,299 -----
  				if (ep->d_ino == 0)
  					continue;
  				copdent(d_name, ep->d_name);
+ 				if (*d_name == '.')
+ 					continue;
+ 
+ 				strcpy (fnamebuf, *pv);
+ 				strcat (fnamebuf, "/");
+ 				strcat (fnamebuf, d_name);
+ 
+ 				if (access(fnamebuf, 1)) /* if not exe file */
+ 					continue;
+ 
  				xhash[hash(d_name)] |= (1 << i);
  				tw_add_comm_name (d_name);
  			}
***************
*** 280,285
  					continue;
  				copdent(d_name, ep->d_name);
  				xhash[hash(d_name)] |= (1 << i);
  			}
  		}
  		close(dirf);

--- 295,301 -----
  					continue;
  
  				xhash[hash(d_name)] |= (1 << i);
+ 				tw_add_comm_name (d_name);
  			}
  		}
  		close(dirf);
***************
*** 284,289
  		}
  		close(dirf);
  	}
  }
  
  dounhash()

--- 300,308 -----
  		}
  		close(dirf);
  	}
+ 	tw_add_builtins();
+ 	tw_add_aliases();
+ 	tw_sort_comms ();	/* re-build the command path for twenex.c */
  }
  
  dounhash()

========	diff -bc csh/sh.func.c tcsh/sh.func.c	========

*** csh/sh.func.c	Fri Apr 13 10:44:03 1984
--- tcsh/sh.func.c	Fri Apr 13 10:45:07 1984
***************
*** 498,504
  		bseek(0l);
  	do {
  		if (intty && fseekp == feobp)
! 			printf("? "), flush();
  		aword[0] = 0, getword(aword);
  		switch (srchx(aword)) {
  

--- 498,504 -----
  		bseek(0l);
  	do {
  		if (intty && fseekp == feobp)
! 			printprompt(); /* printf("? "), flush(); */
  		aword[0] = 0, getword(aword);
  		switch (srchx(aword)) {
  
***************
*** 727,732
  		blkfree(gargv), gargv = 0;
  }
  
  char	**environ;
  
  dosetenv(v)

--- 727,733 -----
  		blkfree(gargv), gargv = 0;
  }
  
+ 
  char	**environ;
  
  dosetenv(v)
***************
*** 1005,1012
  	int old, ldisc;
  	short ctpgrp;
  
! 	if (loginsh)
! 		error("Can't suspend a login shell (yet)");
  	untty();
  	old = sigsys(SIGTSTP, SIG_DFL);
  	kill(0, SIGTSTP);

--- 1006,1063 -----
  	int old, ldisc;
  	short ctpgrp;
  
! 	if (loginsh) {
! 		error ("Use \'detach\' to suspend the login shell.");
! 	}
! 	untty();
! 	old = sigsys(SIGTSTP, SIG_DFL);
! 	kill(0, SIGTSTP);
! 	/* the shell stops here */
! 	sigsys(SIGTSTP, old);
! 	if (tpgrp != -1) {
! retry:
! 		ioctl(FSHTTY, TIOCGPGRP, &ctpgrp);
! 		if (ctpgrp != opgrp) {
! 			old = sigsys(SIGTTIN, SIG_DFL);
! 			kill(0, SIGTTIN);
! 			sigsys(SIGTTIN, old);
! 			goto retry;
! 		}
! 		ioctl(FSHTTY, TIOCSPGRP, &shpgrp);
! 		setpgrp(0, shpgrp);
! 	}
! 	ioctl(FSHTTY, TIOCGETD, &oldisc);
! 	if (oldisc != NTTYDISC) {
! 		printf("Switching to new tty driver...\n");
! 		ldisc = NTTYDISC;
! 		ioctl(FSHTTY, TIOCSETD, &ldisc);
! 	}
! }
! 
! /* dodetach - try to stop the shell and insulate it from the SIGKILL that
!    init will send it by forking and having the PARENT exit(0) */
! 
! dodetach()
! {
! 	int old, ldisc;
! 	short ctpgrp;
! 	int fork_val;
! 
! 	if (!loginsh) {
! 		dosuspend();
! 		return;
! 	}
! 	printf ("Trying to detach, hang on...");
! /* try to clone yourself */
! 	fork_val = fork();
! 
! /* if you did, then die, else spit an error */
! 	if (fork_val == -1) {
! 		error ("Could not make the fork for detaching.");
! 	} else if (fork_val != 0) {
! 		exit (0);	/* parent fork dies at this point, leaving
! 				   the orphan which we now are */
! 	}
  	untty();
  	old = sigsys(SIGTSTP, SIG_DFL);
  	kill(0, SIGTSTP);

========	diff -bc csh/sh.h tcsh/sh.h	========

*** csh/sh.h	Fri Apr 13 10:44:07 1984
--- tcsh/sh.h	Fri Apr 13 10:45:09 1984
***************
*** 5,10
  #include <sys/vtimes.h>
  #endif
  
  /*
   * C shell
   *

--- 5,12 -----
  #include <sys/vtimes.h>
  #endif
  
+ #define OSU
+ 				/* do the ohio state changes */
  /*
   * C shell
   *
***************
*** 73,79
  short	opgrp;			/* Initial pgrp and tty pgrp */
  int	oldisc;			/* Initial line discipline or -1 */
  struct	tms shtimes;		/* shell and child times for process timing */
! 
  /*
   * These are declared here because they want to be
   * initialized in sh.init.c (to allow them to be made readonly)

--- 75,83 -----
  short	opgrp;			/* Initial pgrp and tty pgrp */
  int	oldisc;			/* Initial line discipline or -1 */
  struct	tms shtimes;		/* shell and child times for process timing */
! char PromptBuf[256];		/* buffer for the actual printed prompt.
! 				   this is used in tenex.c and sh.c for
! 				   pegets.c */
  /*
   * These are declared here because they want to be
   * initialized in sh.init.c (to allow them to be made readonly)

========	diff -bc csh/sh.init.c tcsh/sh.init.c	========

*** csh/sh.init.c	Fri Apr 13 10:44:07 1984
--- tcsh/sh.init.c	Fri Apr 13 10:45:11 1984
***************
*** 8,13
  
  extern	int doalias();
  extern	int dobg();
  extern	int dobreak();
  extern	int dochngd();
  extern	int docontin();

--- 8,14 -----
  
  extern	int doalias();
  extern	int dobg();
+ extern	int dobind();
  extern	int dobreak();
  extern	int dochngd();
  extern	int docontin();
***************
*** 11,16
  extern	int dobreak();
  extern	int dochngd();
  extern	int docontin();
  extern	int dodirs();
  extern	int doecho();
  extern	int doelse();

--- 12,18 -----
  extern	int dobreak();
  extern	int dochngd();
  extern	int docontin();
+ extern	int dodetach();
  extern	int dodirs();
  extern	int doecho();
  extern	int doelse();
***************
*** 78,83
  	"alloc",	showall,	0,	1,
  #endif
  	"bg",		dobg,		0,	INF,
  	"break",	dobreak,	0,	0,
  	"breaksw",	doswbrk,	0,	0,
  #ifdef IIASA

--- 80,86 -----
  	"alloc",	showall,	0,	1,
  #endif
  	"bg",		dobg,		0,	INF,
+ 	"bind",		dobind,		0,	2,
  	"break",	dobreak,	0,	0,
  	"breaksw",	doswbrk,	0,	0,
  #ifdef IIASA
***************
*** 88,93
  	"chdir",	dochngd,	0,	1,
  	"continue",	docontin,	0,	0,
  	"default",	dozip,		0,	0,
  	"dirs",		dodirs,		0,	1,
  	"echo",		doecho,		0,	INF,
  	"else",		doelse,		0,	INF,

--- 91,97 -----
  	"chdir",	dochngd,	0,	1,
  	"continue",	docontin,	0,	0,
  	"default",	dozip,		0,	0,
+ /* 	"detach",	dodetach,	0,	0,	 */
  	"dirs",		dodirs,		0,	1,
  	"echo",		doecho,		0,	INF,
  	"else",		doelse,		0,	INF,

========	diff -bc csh/sh.lex.c tcsh/sh.lex.c	========

*** csh/sh.lex.c	Fri Apr 13 10:44:09 1984
--- tcsh/sh.lex.c	Fri Apr 13 10:45:14 1984
***************
*** 1,4
  static	char *sccsid = "@(#)sh.lex.c 4.1 10/9/80";
  
  #include "sh.h"
  

--- 1,5 -----
  static  char *sccsid = "@(#)sh.lex.c 4.1 10/9/80";
+ static char *SCCSid = "@(#)sh.lex.c     1.3 - 1/1/82 13:57:46 - HP/CRC";
  
  #include "sh.h"
  
***************
*** 1169,1174
  bgetc()
  {
  	register int buf, off, c;
  
  #ifdef TELL
  	if (cantell) {

--- 1170,1177 -----
  bgetc()
  {
          register int buf, off, c;
+         char ttyline[BUFSIZ];
+         register int numleft = 0, roomleft;
  
  #ifdef TELL
          if (cantell) {
***************
*** 1207,1212
  	if (fseekp >= feobp) {
  		buf = (int) feobp / BUFSIZ;
  		off = (int) feobp % BUFSIZ;
  		do
  			c = read(SHIN, fbuf[buf] + off, BUFSIZ - off);
  		while (c < 0 && errno == EINTR);

--- 1210,1216 -----
          if (fseekp >= feobp) {
                  buf = (int) feobp / BUFSIZ;
                  off = (int) feobp % BUFSIZ;
+                 roomleft = BUFSIZ - off;
                  do
                      if (intty)                  /* then use tenex routine */
                      {
***************
*** 1208,1214
  		buf = (int) feobp / BUFSIZ;
  		off = (int) feobp % BUFSIZ;
  		do
! 			c = read(SHIN, fbuf[buf] + off, BUFSIZ - off);
  		while (c < 0 && errno == EINTR);
  		if (c <= 0)
  			return (-1);

--- 1212,1235 -----
                  off = (int) feobp % BUFSIZ;
                  roomleft = BUFSIZ - off;
                  do
!                     if (intty)                  /* then use tenex routine */
!                     {
!                         c = numleft ? numleft : 
! 			    (isatty (SHIN) ? twenex(ttyline, BUFSIZ) :
! 					     read(SHIN, ttyline, BUFSIZ) );
!                         if (c > roomleft)       /* No room in this buffer? */
!                         {
!                             /* start with fresh buffer */
!                             feobp = fseekp = fblocks * BUFSIZ;
!                             numleft = c;
!                             goto again;
!                         }
!                         if (c > 0)
!                             copy (fbuf[buf] + off, ttyline, c);
!                         numleft = 0;
!                     }
!                     else
!                         c = read(SHIN, fbuf[buf] + off, roomleft);
                  while (c < 0 && errno == EINTR);
                  if (c <= 0)
                          return (-1);
***************
*** 1213,1218
  		if (c <= 0)
  			return (-1);
  		feobp += c;
  		goto again;
  	}
  	c = fbuf[buf][(int) fseekp % BUFSIZ];

--- 1234,1240 -----
                  if (c <= 0)
                          return (-1);
                  feobp += c;
+                 if (!intty)
                      goto again;
          }
          c = fbuf[buf][(int) fseekp % BUFSIZ];

========	diff -bc csh/sh.misc.c tcsh/sh.misc.c	========

*** csh/sh.misc.c	Fri Apr 13 10:44:10 1984
--- tcsh/sh.misc.c	Fri Apr 13 10:45:16 1984
***************
*** 370,372
  			return (0);
  	}
  }

--- 370,413 -----
  			return (0);
  	}
  }
+ 
+ itoa(n, s)			/* convert n to characters in s */
+ int n;
+ char *s;
+ {
+     int i, sign;
+     
+     if ((sign = n) < 0) 	/* record sign */
+ 	n = -n;
+     i = 0;
+     do {
+ 	s[i++] = n % 10 + '0';
+     } while ((n /= 10) > 0);
+     if (sign < 0)
+ 	s[i++] = '-';
+     s[i] = '\0';
+     Reverse(s);
+ }
+ 
+ Reverse(s)
+ char *s;
+ {
+ 	int c, i, j;
+ 
+ 	for (i=0, j = strlen(s)-1; i < j; i++, j--) {
+ 		c = s[i];
+ 		s[i] = s[j];
+ 		s[j] = c;
+ 	}
+ }
+ 
+ #include <sgtty.h>
+ 
+ isatty(f)
+ {
+ 	struct sgttyb ttyb;
+ 
+ 	if (gtty(f, &ttyb) < 0)
+ 		return(0);
+ 	return(1);
+ }

========	diff -bc csh/sh.proc.c tcsh/sh.proc.c	========

*** csh/sh.proc.c	Fri Apr 13 10:44:16 1984
--- tcsh/sh.proc.c	Fri Apr 13 10:45:22 1984
***************
*** 299,305
  	register int index;
  
  	if (pp->p_pid == 0) {
! 		printf("BUG: process flushed twice");
  		return;
  	}
  	while (pp->p_pid != pp->p_jobid)

--- 299,305 -----
  	register int index;
  
  	if (pp->p_pid == 0) {
! 		printf("BUG: process flushed twice\n");
  		return;
  	}
  	while (pp->p_pid != pp->p_jobid)
***************
*** 605,611
  					break;
  
  				default:
! 					printf("BUG: status=%-9o", status);
  				}
  			}
  		}

--- 605,611 -----
  					break;
  
  				default:
! 					printf("BUG: status=%-9o\n", status);
  				}
  			}
  		}

========	diff -bc csh/sh.set.c tcsh/sh.set.c	========

*** csh/sh.set.c	Fri Apr 13 10:44:20 1984
--- tcsh/sh.set.c	Fri Apr 13 10:45:24 1984
***************
*** 73,79
  
  			HIST = *p++;
  			HISTSUB = *p;
! 		} else if (eq(vp, "user"))
  			setenv("USER", value(vp));
  		else if (eq(vp, "term"))
  			setenv("TERM", value(vp));

--- 73,79 -----
  
  			HIST = *p++;
  			HISTSUB = *p;
! 		} else if (eq(vp, "user")) {
  			setenv("USER", value(vp));
  		} else if (eq(vp, "shlvl")) {
  			setenv("SHLVL", value(vp));
***************
*** 75,83
  			HISTSUB = *p;
  		} else if (eq(vp, "user"))
  			setenv("USER", value(vp));
! 		else if (eq(vp, "term"))
! 			setenv("TERM", value(vp));
! 		else if (eq(vp, "home"))
  			setenv("HOME", value(vp));
  	} while (p = *v++);
  }

--- 75,83 -----
  			HISTSUB = *p;
  		} else if (eq(vp, "user")) {
  			setenv("USER", value(vp));
! 		} else if (eq(vp, "shlvl")) {
! 			setenv("SHLVL", value(vp));
! 		} else if (eq(vp, "home")) {
  			setenv("HOME", value(vp));
  		} else if (eq(vp, "term")) {
  			setenv("TERM", value(vp));
***************
*** 79,84
  			setenv("TERM", value(vp));
  		else if (eq(vp, "home"))
  			setenv("HOME", value(vp));
  	} while (p = *v++);
  }
  

--- 79,88 -----
  			setenv("SHLVL", value(vp));
  		} else if (eq(vp, "home")) {
  			setenv("HOME", value(vp));
+ 		} else if (eq(vp, "term")) {
+ 			setenv("TERM", value(vp));
+ 			ilsetup(SHIN, SHOUT);
+ 			}
  	} while (p = *v++);
  }

!Funky!Stuff!



More information about the Comp.sources.unix mailing list