home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume11 / tcsh / part06 < prev    next >
Text File  |  1987-08-10  |  52KB  |  2,215 lines

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i006:  New version of T-shell, Part06/06
  5. Message-ID: <864@uunet.UU.NET>
  6. Date: 11 Aug 87 23:53:40 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 2204
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: Paul Placeway <pyramid!osu-eddie!paul>
  12. Posting-number: Volume 10, Issue 6
  13. Archive-name: tcsh/Part06
  14.  
  15. # This is a shell archive.  Remove anything before this line
  16. # then unpack it by saving it in a file and typing "sh file"
  17. # (Files unpacked will be owned by you and have default permissions).
  18. # This archive contains the following files:
  19. #    ./DIFFS.1
  20. #
  21. if `test ! -s ./DIFFS.1`
  22. then
  23. echo "writing ./DIFFS.1"
  24. sed 's/^x//' > ./DIFFS.1 << '\Rogue\Monster\'
  25. xNo differences encountered
  26. xNo differences encountered
  27. xNo differences encountered
  28. xNo differences encountered
  29. x*** ../csh4.2/sh.c    Tue Jun 23 12:13:44 1987
  30. x--- sh.c    Sat Jul 18 11:39:42 1987
  31. x***************
  32. x*** 1,4
  33. x  static    char *sccsid = "@(#)sh.c 4.12 6/11/83";
  34. x  
  35. x  #include "sh.h"
  36. x  #include <sys/ioctl.h>
  37. x
  38. x--- 1,5 -----
  39. x  static    char *sccsid = "@(#)sh.c 4.12 6/11/83";
  40. x+ static char *Version = "tcsh 5.4 (Ohio State) 7/18/87 Patch level 0";
  41. x  
  42. x  #include "sh.h"
  43. x  /* #include <sys/ioctl.h> */
  44. x***************
  45. x*** 1,7
  46. x  static    char *sccsid = "@(#)sh.c 4.12 6/11/83";
  47. x  
  48. x  #include "sh.h"
  49. x! #include <sys/ioctl.h>
  50. x  /*
  51. x   * C Shell
  52. x   *
  53. x
  54. x--- 2,19 -----
  55. x  static char *Version = "tcsh 5.4 (Ohio State) 7/18/87 Patch level 0";
  56. x  
  57. x  #include "sh.h"
  58. x! /* #include <sys/ioctl.h> */
  59. x! 
  60. x! #ifdef SVID
  61. x! struct termio termiob;
  62. x! 
  63. x! # ifdef OREO
  64. x! struct ltchars ltcbuf;
  65. x! #include <compat.h>
  66. x! # endif OREO
  67. x! 
  68. x! #endif SVID
  69. x! 
  70. x  /*
  71. x   * C Shell
  72. x   *
  73. x***************
  74. x*** 10,15
  75. x   *
  76. x   * Jim Kulp, IIASA, Laxenburg, Austria
  77. x   * April 1980
  78. x   */
  79. x  
  80. x  char    *pathlist[] =    { ".", "/usr/ucb", "/bin", "/usr/bin", 0 };
  81. x
  82. x--- 22,47 -----
  83. x   *
  84. x   * Jim Kulp, IIASA, Laxenburg, Austria
  85. x   * April 1980
  86. x+  *
  87. x+  * Filename recognition added:
  88. x+  * Ken Greer, Ind. Consultant, Palo Alto CA
  89. x+  * October 1983.
  90. x+  *
  91. x+  * Karl Kleinpaste, Computer Consoles, Inc.
  92. x+  * Added precmd, periodic/tperiod, prompt changes,
  93. x+  * directory stack hack, and login watch.
  94. x+  * Sometime March 1983 - Feb 1984.
  95. x+  *
  96. x+  * Added scheduled commands, including the "sched" command,
  97. x+  * plus the call to sched_run near the precmd et al
  98. x+  * routines.
  99. x+  * Upgraded scheduled events for running events while
  100. x+  * sitting idle at command input.
  101. x+  *
  102. x+  * Paul Placeway, Ohio State
  103. x+  * added stuff for running with twenex/inputl  9 Oct 1984.
  104. x+  *
  105. x+  * ported to Apple Unix (TM) (OREO)  26 -- 29 Jun 1987
  106. x   */
  107. x  
  108. x  char    *pathlist[] =    { ".", "/u/osu/bin", "/usr/ucb", "/bin",
  109. x***************
  110. x*** 12,18
  111. x   * April 1980
  112. x   */
  113. x  
  114. x! char    *pathlist[] =    { ".", "/usr/ucb", "/bin", "/usr/bin", 0 };
  115. x  char    *dumphist[] =    { "history", "-h", 0, 0 };
  116. x  char    *loadhist[] =    { "source", "-h", "~/.history", 0 };
  117. x  char    HIST = '!';
  118. x
  119. x--- 44,51 -----
  120. x   * ported to Apple Unix (TM) (OREO)  26 -- 29 Jun 1987
  121. x   */
  122. x  
  123. x! char    *pathlist[] =    { ".", "/u/osu/bin", "/usr/ucb", "/bin",
  124. x!               "/usr/bin", 0 };
  125. x  char    *dumphist[] =    { "history", "-h", 0, 0 };
  126. x  char    *loadhist[] =    { "source", "-h", "~/.history", 0 };
  127. x  /* char    HIST = '!'; */
  128. x***************
  129. x*** 15,22
  130. x  char    *pathlist[] =    { ".", "/usr/ucb", "/bin", "/usr/bin", 0 };
  131. x  char    *dumphist[] =    { "history", "-h", 0, 0 };
  132. x  char    *loadhist[] =    { "source", "-h", "~/.history", 0 };
  133. x! char    HIST = '!';
  134. x! char    HISTSUB = '^';
  135. x  bool    nofile;
  136. x  bool    reenter;
  137. x  bool    nverbose;
  138. x
  139. x--- 48,55 -----
  140. x                "/usr/bin", 0 };
  141. x  char    *dumphist[] =    { "history", "-h", 0, 0 };
  142. x  char    *loadhist[] =    { "source", "-h", "~/.history", 0 };
  143. x! /* char    HIST = '!'; */
  144. x! /* char    HISTSUB = '^'; */
  145. x  bool    nofile;
  146. x  bool    reenter;
  147. x  bool    nverbose;
  148. x***************
  149. x*** 25,30
  150. x  bool    fast;
  151. x  bool    prompt = 1;
  152. x  bool    enterhist = 0;
  153. x  
  154. x  main(c, av)
  155. x      int c;
  156. x
  157. x--- 58,71 -----
  158. x  bool    fast;
  159. x  bool    prompt = 1;
  160. x  bool    enterhist = 0;
  161. x+ bool    tellwhat = 0;
  162. x+ int    phup();
  163. x+ time_t    t_period;
  164. x+ time_t    watch_period = 0;
  165. x+ struct who *wholist;
  166. x+ bool    precmd_active = 0;
  167. x+ bool    periodic_active = 0;
  168. x+ char    buff[128];        /* for gethostname(2), and printprompt() */
  169. x  
  170. x  #define DEFAULT_AUTOLOGOUT    "60"    /* 1 Hour Alarm default */
  171. x  
  172. x***************
  173. x*** 26,31
  174. x  bool    prompt = 1;
  175. x  bool    enterhist = 0;
  176. x  
  177. x  main(c, av)
  178. x      int c;
  179. x      char **av;
  180. x
  181. x--- 67,100 -----
  182. x  bool    periodic_active = 0;
  183. x  char    buff[128];        /* for gethostname(2), and printprompt() */
  184. x  
  185. x+ #define DEFAULT_AUTOLOGOUT    "60"    /* 1 Hour Alarm default */
  186. x+ 
  187. x+ auto_logout ()
  188. x+ {
  189. x+     printf ("auto-logout\n");
  190. x+     close (SHIN);
  191. x+     set ("logout", "automatic");
  192. x+     child++;
  193. x+     goodbye ();
  194. x+ }
  195. x+ 
  196. x+ alrmcatch ()
  197. x+ {
  198. x+     extern    struct    sched_event *sched_ptr;
  199. x+     time_t    cl;
  200. x+ 
  201. x+     if (!sched_ptr)
  202. x+         auto_logout();    /* no other possibility - logout */
  203. x+     time(&cl);
  204. x+     if (sched_ptr->t_when <= cl + 1)
  205. x+         sched_run();
  206. x+     else
  207. x+         auto_logout();
  208. x+     setalarm();
  209. x+ }
  210. x+ 
  211. x+ char    *ttyname();
  212. x+ 
  213. x  main(c, av)
  214. x      int c;
  215. x      char **av;
  216. x***************
  217. x*** 34,39
  218. x      register int f;
  219. x  
  220. x      settimes();            /* Immed. estab. timing base */
  221. x      v = av;
  222. x      if (eq(v[0], "a.out"))        /* A.out's are quittable */
  223. x          quitit = 1;
  224. x
  225. x--- 103,116 -----
  226. x      register int f;
  227. x  
  228. x      settimes();            /* Immed. estab. timing base */
  229. x+ #ifdef OREO
  230. x+     set42sig();
  231. x+     setcompat (COMPAT_BSDPROT | COMPAT_BSDNBIO | COMPAT_BSDSIGNALS |
  232. x+           COMPAT_SYSCALLS);
  233. x+ #endif
  234. x+     HIST = '!';
  235. x+     HISTSUB = '^';
  236. x+ 
  237. x      v = av;
  238. x      if (eq(v[0], "a.out"))        /* A.out's are quittable */
  239. x          quitit = 1;
  240. x***************
  241. x*** 43,48
  242. x          time(&chktim);
  243. x  
  244. x      /*
  245. x       * Move the descriptors to safe places.
  246. x       * The variable didfds is 0 while we have only FSH* to work with.
  247. x       * When didfds is true, we have 0,1,2 and prefer to use these.
  248. x
  249. x--- 120,132 -----
  250. x          time(&chktim);
  251. x  
  252. x      /*
  253. x+      * Initialize for periodic command intervals.
  254. x+      * Also, initialize the dummy tty list for login-watch.
  255. x+      */
  256. x+     time(&t_period);
  257. x+     initwatch();
  258. x+ 
  259. x+     /*
  260. x       * Move the descriptors to safe places.
  261. x       * The variable didfds is 0 while we have only FSH* to work with.
  262. x       * When didfds is true, we have 0,1,2 and prefer to use these.
  263. x***************
  264. x*** 56,61
  265. x       * CHILD is munged when forking/waiting
  266. x       */
  267. x  
  268. x      set("status", "0");
  269. x      dinit(cp = getenv("HOME"));    /* dinit thinks that HOME == cwd in a
  270. x                       * login shell */
  271. x
  272. x--- 140,169 -----
  273. x       * CHILD is munged when forking/waiting
  274. x       */
  275. x      
  276. x+     /* 7-10-87 Paul Placeway
  277. x+      * autologout should be set ONLY on login shells and on shells
  278. x+      * running as root.  Out of these, autologout should NOT be set
  279. x+      * for any psudo-terminals (this catches most window systems)
  280. x+      * and not for any terminal running X windows.
  281. x+      *
  282. x+      * At Ohio State, we have had problems with a user having his
  283. x+      * X session drop out from under him (on a Sun) because the shell
  284. x+      * in his master xterm timed out and exited.
  285. x+      *
  286. x+      * Really, this should be done with a program external to the
  287. x+      * shell, that watches for no activity (and NO running programs,
  288. x+      * such as dump) on a terminal for a long peroid of time, and
  289. x+      * then SIGHUPS the shell on that terminal.
  290. x+      */
  291. x+     if (loginsh || getuid() == 0) { /* only for login shells or root */
  292. x+         cp = ttyname(SHIN);
  293. x+         if ((strncmp (cp, "ttyp", 4) != 0) &&
  294. x+         (strncmp (cp, "ttyp", 4) != 0))
  295. x+         if (getenv("DISPLAY") == NOSTR) /* NOT on X window shells */
  296. x+             set("autologout", DEFAULT_AUTOLOGOUT);
  297. x+     }
  298. x+ 
  299. x+     sigset (SIGALRM, alrmcatch);
  300. x      set("status", "0");
  301. x      set("tcsh", "1");        /* so I can tell the difference */
  302. x      dinit(cp = getenv("HOME"));    /* dinit thinks that HOME == cwd in a
  303. x***************
  304. x*** 57,62
  305. x       */
  306. x  
  307. x      set("status", "0");
  308. x      dinit(cp = getenv("HOME"));    /* dinit thinks that HOME == cwd in a
  309. x                       * login shell */
  310. x      if (cp == NOSTR)
  311. x
  312. x--- 165,171 -----
  313. x  
  314. x      sigset (SIGALRM, alrmcatch);
  315. x      set("status", "0");
  316. x+     set("tcsh", "1");        /* so I can tell the difference */
  317. x      dinit(cp = getenv("HOME"));    /* dinit thinks that HOME == cwd in a
  318. x                       * login shell */
  319. x      if (cp == NOSTR)
  320. x***************
  321. x*** 71,76
  322. x          set("user", savestr(cp));
  323. x      if ((cp = getenv("TERM")) != NOSTR)
  324. x          set("term", savestr(cp));
  325. x      /*
  326. x       * Re-initialize path if set in environment
  327. x       */
  328. x
  329. x--- 180,187 -----
  330. x          set("user", savestr(cp));
  331. x      if ((cp = getenv("TERM")) != NOSTR)
  332. x          set("term", savestr(cp));
  333. x+ 
  334. x+     set ("version", Version); /* publish the shell version */
  335. x      /*
  336. x       * set usefull environment things for the user
  337. x       */
  338. x***************
  339. x*** 72,77
  340. x      if ((cp = getenv("TERM")) != NOSTR)
  341. x          set("term", savestr(cp));
  342. x      /*
  343. x       * Re-initialize path if set in environment
  344. x       */
  345. x      if ((cp = getenv("PATH")) == NOSTR)
  346. x
  347. x--- 183,223 -----
  348. x  
  349. x      set ("version", Version); /* publish the shell version */
  350. x      /*
  351. x+      * set usefull environment things for the user
  352. x+      */
  353. x+     itoa (getuid(), buff);
  354. x+     set ("uid", buff);
  355. x+     if ((cp = getenv("HOST")) == NOSTR) { /* if not allready set */
  356. x+         gethostname (buff, sizeof(buff));
  357. x+         buff[sizeof(buff) -1] = '\0'; /* just in case */
  358. x+         setenv ("HOST", buff);
  359. x+     }
  360. x+     if ((cp = getenv("HOSTTYPE")) == NOSTR) { /* if not allready set */
  361. x+ #ifdef vax
  362. x+         setenv ("HOSTTYPE", "vax");
  363. x+ #endif
  364. x+ #ifdef sun
  365. x+ # ifdef mc68010
  366. x+         setenv ("HOSTTYPE", "sun2");
  367. x+ # else
  368. x+ #  ifdef mc68020
  369. x+         setenv ("HOSTTYPE", "sun3");
  370. x+ #  else
  371. x+         setenv ("HOSTTYPE", "sun");
  372. x+ #  endif
  373. x+ # endif
  374. x+ #endif
  375. x+ #ifdef pyr            /* pyramid */
  376. x+         setenv ("HOSTTYPE", "pyramid");
  377. x+ #endif
  378. x+ #ifdef OREO
  379. x+         setenv ("HOSTTYPE", "mac2");
  380. x+ #endif OREO
  381. x+ #ifdef ns32000                  /* ugh!  This should change */
  382. x+             setenv ("HOSTTYPE", "multimax");
  383. x+ #endif
  384. x+     }
  385. x+     /*
  386. x       * Re-initialize path if set in environment
  387. x       */
  388. x      if ((cp = getenv("PATH")) == NOSTR)
  389. x***************
  390. x*** 244,251
  391. x      /*
  392. x       * Set up the prompt.
  393. x       */
  394. x!     if (prompt)
  395. x!         set("prompt", uid == 0 ? "# " : "% ");
  396. x  
  397. x      /*
  398. x       * If we are an interactive shell, then start fiddling
  399. x
  400. x--- 390,399 -----
  401. x      /*
  402. x       * Set up the prompt.
  403. x       */
  404. x!     if (prompt) {
  405. x!         set("prompt", uid == 0 ? "# " : "> ");
  406. x!         set("prompt2", "\277 "); /* that's a meta-questionmark */
  407. x!     }
  408. x  
  409. x      /*
  410. x       * If we are an interactive shell, then start fiddling
  411. x***************
  412. x*** 280,285
  413. x              else
  414. x                  f = -1;
  415. x  retry:
  416. x              if (ioctl(f, TIOCGPGRP, &tpgrp) == 0 && tpgrp != -1) {
  417. x                  int ldisc;
  418. x                  if (tpgrp != shpgrp) {
  419. x
  420. x--- 428,434 -----
  421. x              else
  422. x                  f = -1;
  423. x  retry:
  424. x+ #ifdef BSDJOBS            /* if we have tty job control */
  425. x              if (ioctl(f, TIOCGPGRP, &tpgrp) == 0 && tpgrp != -1) {
  426. x                  int ldisc;
  427. x                  if (tpgrp != shpgrp) {
  428. x***************
  429. x*** 288,293
  430. x                      sigsys(SIGTTIN, old);
  431. x                      goto retry;
  432. x                  }
  433. x                  if (ioctl(f, TIOCGETD, &oldisc) != 0) 
  434. x                      goto notty;
  435. x                  if (oldisc != NTTYDISC) {
  436. x
  437. x--- 437,469 -----
  438. x                      sigsys(SIGTTIN, old);
  439. x                      goto retry;
  440. x                  }
  441. x+ # ifdef OREO
  442. x+                 if (ioctl(f, TCGETA, &termiob) != 0)
  443. x+                     goto notty;
  444. x+                 if ((getcompat(COMPAT_BSDTTY) & COMPAT_BSDTTY)
  445. x+                     != COMPAT_BSDTTY) {
  446. x+ #  ifdef DEBUG
  447. x+                     printf("Switching to new tty driver...\n");
  448. x+ #  endif DEBUG
  449. x+                     setcompat(COMPAT_BSDTTY);
  450. x+                     if (ioctl (f, TIOCGLTC, <cbuf) < 0) {
  451. x+                     printf ("Couldn't get local chars.\n");
  452. x+                     } else {
  453. x+ #  ifdef DEBUG
  454. x+                     printf ("Setting ^Z, etc....\n");
  455. x+ #  endif DEBUG
  456. x+                     ltcbuf.t_suspc = '\032'; /* ^Z */
  457. x+                     ltcbuf.t_dsuspc = '\031'; /* ^Y */
  458. x+                     ltcbuf.t_rprntc = '\022'; /* ^R */
  459. x+                     ltcbuf.t_flushc = '\017'; /* ^O */
  460. x+                     ltcbuf.t_werasc = '\027'; /* ^W */
  461. x+                     ltcbuf.t_lnextc = '\026'; /* ^V */
  462. x+                     ioctl (f, TIOCSLTC, <cbuf);
  463. x+                     }
  464. x+                     termiob.c_cc[VSWTCH] = '\0';
  465. x+                     ioctl(f, TCSETAF, &termiob);
  466. x+                 }
  467. x+ # else OREO
  468. x                  if (ioctl(f, TIOCGETD, &oldisc) != 0) 
  469. x                      goto notty;
  470. x                  if (oldisc != NTTYDISC) {
  471. x***************
  472. x*** 291,297
  473. x                  if (ioctl(f, TIOCGETD, &oldisc) != 0) 
  474. x                      goto notty;
  475. x                  if (oldisc != NTTYDISC) {
  476. x! #ifdef DEBUG
  477. x                      printf("Switching to new tty driver...\n");
  478. x  #endif DEBUG
  479. x                      ldisc = NTTYDISC;
  480. x
  481. x--- 467,473 -----
  482. x                  if (ioctl(f, TIOCGETD, &oldisc) != 0) 
  483. x                      goto notty;
  484. x                  if (oldisc != NTTYDISC) {
  485. x! #  ifdef DEBUG
  486. x                      printf("Switching to new tty driver...\n");
  487. x  #  endif DEBUG
  488. x                      ldisc = NTTYDISC;
  489. x***************
  490. x*** 293,299
  491. x                  if (oldisc != NTTYDISC) {
  492. x  #ifdef DEBUG
  493. x                      printf("Switching to new tty driver...\n");
  494. x! #endif DEBUG
  495. x                      ldisc = NTTYDISC;
  496. x                      ioctl(f, TIOCSETD, &ldisc);
  497. x                  } else
  498. x
  499. x--- 469,475 -----
  500. x                  if (oldisc != NTTYDISC) {
  501. x  #  ifdef DEBUG
  502. x                      printf("Switching to new tty driver...\n");
  503. x! #  endif DEBUG
  504. x                      ldisc = NTTYDISC;
  505. x                      ioctl(f, TIOCSETD, &ldisc);
  506. x                  } else
  507. x***************
  508. x*** 298,303
  509. x                      ioctl(f, TIOCSETD, &ldisc);
  510. x                  } else
  511. x                      oldisc = -1;
  512. x                  opgrp = shpgrp;
  513. x                  shpgrp = getpid();
  514. x                  tpgrp = shpgrp;
  515. x
  516. x--- 474,480 -----
  517. x                      ioctl(f, TIOCSETD, &ldisc);
  518. x                  } else
  519. x                      oldisc = -1;
  520. x+ # endif OREO
  521. x                  opgrp = shpgrp;
  522. x                  shpgrp = getpid();
  523. x                  tpgrp = shpgrp;
  524. x***************
  525. x*** 310,315
  526. x    printf("Warning: no access to tty; thus no job control in this shell...\n");
  527. x                  tpgrp = -1;
  528. x              }
  529. x          }
  530. x      }
  531. x      if (setintr == 0 && parintr == SIG_DFL)
  532. x
  533. x--- 487,496 -----
  534. x    printf("Warning: no access to tty; thus no job control in this shell...\n");
  535. x                  tpgrp = -1;
  536. x              }
  537. x+ #else BSDJOBS            /* don't have job control, so frotz it */
  538. x+             tpgrp = -1;
  539. x+             printf ("Warning: jobs not implemented yet.\n");
  540. x+ #endif BSDJOBS
  541. x          }
  542. x      }
  543. x      if (setintr == 0 && parintr == SIG_DFL)
  544. x***************
  545. x*** 324,329
  546. x      haderr = 0;        /* In case second time through */
  547. x      if (!fast && reenter == 0) {
  548. x          reenter++;
  549. x          /* Will have value("home") here because set fast if don't */
  550. x          srccat(value("home"), "/.cshrc");
  551. x          if (!fast && !arginp && !onelflg)
  552. x
  553. x--- 505,514 -----
  554. x      haderr = 0;        /* In case second time through */
  555. x      if (!fast && reenter == 0) {
  556. x          reenter++;
  557. x+                 if (!fast && !arginp && !onelflg) { /* PWP setup stuff */
  558. x+             ed_Init();    /* init the new line editor */
  559. x+             /* PWP: setup the editor BEFORE doing .cshrc, else bugs! */
  560. x+         }    
  561. x          /* Will have value("home") here because set fast if don't */
  562. x          srccat(value("home"), "/.cshrc");    /* upward compat. */
  563. x          if (!fast && !arginp && !onelflg)
  564. x***************
  565. x*** 325,331
  566. x      if (!fast && reenter == 0) {
  567. x          reenter++;
  568. x          /* Will have value("home") here because set fast if don't */
  569. x!         srccat(value("home"), "/.cshrc");
  570. x          if (!fast && !arginp && !onelflg)
  571. x              dohash();
  572. x          dosource(loadhist);
  573. x
  574. x--- 510,516 -----
  575. x              /* PWP: setup the editor BEFORE doing .cshrc, else bugs! */
  576. x          }    
  577. x          /* Will have value("home") here because set fast if don't */
  578. x!         srccat(value("home"), "/.cshrc");    /* upward compat. */
  579. x          if (!fast && !arginp && !onelflg)
  580. x              dohash();
  581. x          dosource(loadhist);
  582. x***************
  583. x*** 353,358
  584. x      /*
  585. x       * Mop-up.
  586. x       */
  587. x      if (loginsh) {
  588. x          printf("logout\n");
  589. x          close(SHIN);
  590. x
  591. x--- 538,544 -----
  592. x      /*
  593. x       * Mop-up.
  594. x       */
  595. x+     if (intty) {
  596. x          if (loginsh) {
  597. x          printf("logout\n");
  598. x          close(SHIN);
  599. x***************
  600. x*** 358,363
  601. x          close(SHIN);
  602. x          child++;
  603. x          goodbye();
  604. x      }
  605. x      rechist();
  606. x      exitstat();
  607. x
  608. x--- 544,551 -----
  609. x          close(SHIN);
  610. x          child++;
  611. x          goodbye();
  612. x+         } else {
  613. x+         printf ("exit\n");
  614. x          }
  615. x      }
  616. x      rechist();
  617. x***************
  618. x*** 359,364
  619. x          child++;
  620. x          goodbye();
  621. x      }
  622. x      rechist();
  623. x      exitstat();
  624. x  }
  625. x
  626. x--- 547,553 -----
  627. x          } else {
  628. x          printf ("exit\n");
  629. x          }
  630. x+     }
  631. x      rechist();
  632. x      exitstat();
  633. x  }
  634. x***************
  635. x*** 365,371
  636. x  
  637. x  untty()
  638. x  {
  639. x! 
  640. x      if (tpgrp > 0) {
  641. x          setpgrp(0, opgrp);
  642. x          ioctl(FSHTTY, TIOCSPGRP, &opgrp);
  643. x
  644. x--- 554,560 -----
  645. x  
  646. x  untty()
  647. x  {
  648. x! #ifdef BSDJOBS
  649. x      if (tpgrp > 0) {
  650. x          setpgrp(0, opgrp);
  651. x          ioctl(FSHTTY, TIOCSPGRP, &opgrp);
  652. x***************
  653. x*** 369,374
  654. x      if (tpgrp > 0) {
  655. x          setpgrp(0, opgrp);
  656. x          ioctl(FSHTTY, TIOCSPGRP, &opgrp);
  657. x          if (oldisc != -1 && oldisc != NTTYDISC) {
  658. x  #ifdef DEBUG
  659. x              printf("\nReverting to old tty driver...\n");
  660. x
  661. x--- 558,564 -----
  662. x      if (tpgrp > 0) {
  663. x          setpgrp(0, opgrp);
  664. x          ioctl(FSHTTY, TIOCSPGRP, &opgrp);
  665. x+ # ifndef OREO
  666. x          if (oldisc != -1 && oldisc != NTTYDISC) {
  667. x  #  ifdef DEBUG
  668. x              printf("\nReverting to old tty driver...\n");
  669. x***************
  670. x*** 370,376
  671. x          setpgrp(0, opgrp);
  672. x          ioctl(FSHTTY, TIOCSPGRP, &opgrp);
  673. x          if (oldisc != -1 && oldisc != NTTYDISC) {
  674. x! #ifdef DEBUG
  675. x              printf("\nReverting to old tty driver...\n");
  676. x  #endif DEBUG
  677. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  678. x
  679. x--- 560,566 -----
  680. x          ioctl(FSHTTY, TIOCSPGRP, &opgrp);
  681. x  # ifndef OREO
  682. x          if (oldisc != -1 && oldisc != NTTYDISC) {
  683. x! #  ifdef DEBUG
  684. x              printf("\nReverting to old tty driver...\n");
  685. x  #  endif DEBUG
  686. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  687. x***************
  688. x*** 372,378
  689. x          if (oldisc != -1 && oldisc != NTTYDISC) {
  690. x  #ifdef DEBUG
  691. x              printf("\nReverting to old tty driver...\n");
  692. x! #endif DEBUG
  693. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  694. x          }
  695. x      }
  696. x
  697. x--- 562,568 -----
  698. x          if (oldisc != -1 && oldisc != NTTYDISC) {
  699. x  #  ifdef DEBUG
  700. x              printf("\nReverting to old tty driver...\n");
  701. x! #  endif DEBUG
  702. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  703. x          }
  704. x  # endif OREO
  705. x***************
  706. x*** 375,380
  707. x  #endif DEBUG
  708. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  709. x          }
  710. x      }
  711. x  }
  712. x  
  713. x
  714. x--- 565,571 -----
  715. x  #  endif DEBUG
  716. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  717. x          }
  718. x+ # endif OREO
  719. x      }
  720. x  #endif BSDJOBS
  721. x  }
  722. x***************
  723. x*** 376,381
  724. x              ioctl(FSHTTY, TIOCSETD, &oldisc);
  725. x          }
  726. x      }
  727. x  }
  728. x  
  729. x  importpath(cp)
  730. x
  731. x--- 567,573 -----
  732. x          }
  733. x  # endif OREO
  734. x      }
  735. x+ #endif BSDJOBS
  736. x  }
  737. x  
  738. x  importpath(cp)
  739. x***************
  740. x*** 467,474
  741. x      if (onlyown) {
  742. x          struct stat stb;
  743. x  
  744. x!         if (fstat(unit, &stb) < 0 ||
  745. x!             (stb.st_uid != uid && stb.st_gid != getgid())) {
  746. x              close(unit);
  747. x              return;
  748. x          }
  749. x
  750. x--- 659,667 -----
  751. x      if (onlyown) {
  752. x          struct stat stb;
  753. x  
  754. x!         if (fstat(unit, &stb) < 0
  755. x!         /*    || (stb.st_uid != uid && stb.st_gid != getgid()) */
  756. x!         ) {
  757. x              close(unit);
  758. x              return;
  759. x          }
  760. x***************
  761. x*** 576,581
  762. x  
  763. x  goodbye()
  764. x  {
  765. x      if (loginsh) {
  766. x          signal(SIGQUIT, SIG_IGN);
  767. x          sigset(SIGINT, SIG_IGN);
  768. x
  769. x--- 769,775 -----
  770. x  
  771. x  goodbye()
  772. x  {
  773. x+     rechist();
  774. x      if (loginsh) {
  775. x          signal(SIGQUIT, SIG_IGN);
  776. x          sigset(SIGINT, SIG_IGN);
  777. x***************
  778. x*** 581,586
  779. x          sigset(SIGINT, SIG_IGN);
  780. x          signal(SIGTERM, SIG_IGN);
  781. x          setintr = 0;        /* No interrupts after "logout" */
  782. x          if (adrof("home"))
  783. x              srccat(value("home"), "/.logout");
  784. x      }
  785. x
  786. x--- 775,782 -----
  787. x          sigset(SIGINT, SIG_IGN);
  788. x          signal(SIGTERM, SIG_IGN);
  789. x          setintr = 0;        /* No interrupts after "logout" */
  790. x+         if (!(adrof("logout")))
  791. x+             set ("logout", "normal");
  792. x          if (adrof("home"))
  793. x              srccat(value("home"), "/.logout");
  794. x      }
  795. x***************
  796. x*** 584,590
  797. x          if (adrof("home"))
  798. x              srccat(value("home"), "/.logout");
  799. x      }
  800. x-     rechist();
  801. x      exitstat();
  802. x  }
  803. x  
  804. x
  805. x--- 780,785 -----
  806. x          if (adrof("home"))
  807. x              srccat(value("home"), "/.logout");
  808. x      }
  809. x      exitstat();
  810. x  }
  811. x  
  812. x***************
  813. x*** 654,661
  814. x          if (v = gargv)
  815. x              gargv = 0, blkfree(v);
  816. x          reset();
  817. x!     } else if (intty && wantnl)
  818. x!         printf("\n");        /* Some like this, others don't */
  819. x      error(NOSTR);
  820. x  }
  821. x  
  822. x
  823. x--- 849,859 -----
  824. x          if (v = gargv)
  825. x              gargv = 0, blkfree(v);
  826. x          reset();
  827. x!     } else if (intty && wantnl) {
  828. x!         /* printf("\n");    /* Some like this, others don't */
  829. x!         putraw ('\r');
  830. x!         putraw ('\n');
  831. x!     }
  832. x      error(NOSTR);
  833. x  }
  834. x  
  835. x***************
  836. x*** 731,736
  837. x          if (intty && evalvec == 0) {
  838. x              mailchk();
  839. x              /*
  840. x               * If we are at the end of the input buffer
  841. x               * then we are going to read fresh stuff.
  842. x               * Otherwise, we are rereading input and don't
  843. x
  844. x--- 929,944 -----
  845. x          if (intty && evalvec == 0) {
  846. x              mailchk();
  847. x              /*
  848. x+              * Watch for logins/logouts.
  849. x+              * Next is scheduled commands stored previously using "sched."
  850. x+              * Then execute periodic commands.
  851. x+              * Following that, the prompt precmd is run.
  852. x+              */
  853. x+             watch_login();
  854. x+             sched_run();
  855. x+             period_cmd();
  856. x+             precmd();
  857. x+             /*
  858. x               * If we are at the end of the input buffer
  859. x               * then we are going to read fresh stuff.
  860. x               * Otherwise, we are rereading input and don't
  861. x***************
  862. x*** 737,757
  863. x               * need or want to prompt.
  864. x               */
  865. x              if (fseekp == feobp)
  866. x!                 if (!whyles)
  867. x!                     for (cp = value("prompt"); *cp; cp++)
  868. x!                         if (*cp == HIST)
  869. x!                             printf("%d", eventno + 1);
  870. x!                         else {
  871. x!                             if (*cp == '\\' && cp[1] == HIST)
  872. x!                                 cp++;
  873. x!                             putchar(*cp | QUOTE);
  874. x!                         }
  875. x!                 else
  876. x!                     /*
  877. x!                      * Prompt for forward reading loop
  878. x!                      * body content.
  879. x!                      */
  880. x!                     printf("? ");
  881. x              flush();
  882. x          }
  883. x          err = 0;
  884. x
  885. x--- 945,951 -----
  886. x               * need or want to prompt.
  887. x               */
  888. x              if (fseekp == feobp)
  889. x!                 printprompt ();
  890. x              flush();
  891. x              setalarm();
  892. x          }
  893. x***************
  894. x*** 753,758
  895. x                       */
  896. x                      printf("? ");
  897. x              flush();
  898. x          }
  899. x          err = 0;
  900. x  
  901. x
  902. x--- 947,953 -----
  903. x              if (fseekp == feobp)
  904. x                  printprompt ();
  905. x              flush();
  906. x+             setalarm();
  907. x          }
  908. x          err = 0;
  909. x  
  910. x***************
  911. x*** 760,766
  912. x           * Echo not only on VERBOSE, but also with history expansion.
  913. x           * If there is a lexical error then we forego history echo.
  914. x           */
  915. x!         if (lex(¶ml) && !err && intty ||
  916. x              adrof("verbose")) {
  917. x              haderr = 1;
  918. x              prlex(¶ml);
  919. x
  920. x--- 955,961 -----
  921. x           * Echo not only on VERBOSE, but also with history expansion.
  922. x           * If there is a lexical error then we forego history echo.
  923. x           */
  924. x!         if (lex(¶ml) && !err && intty && !tellwhat ||
  925. x              adrof("verbose")) {
  926. x              haderr = 1;
  927. x              prlex(¶ml);
  928. x***************
  929. x*** 766,771
  930. x              prlex(¶ml);
  931. x              haderr = 0;
  932. x          }
  933. x  
  934. x          /*
  935. x           * The parser may lose space if interrupted.
  936. x
  937. x--- 961,967 -----
  938. x              prlex(¶ml);
  939. x              haderr = 0;
  940. x          }
  941. x+         alarm (0);                /* Autologout OFF */
  942. x  
  943. x          /*
  944. x           * The parser may lose space if interrupted.
  945. x***************
  946. x*** 779,785
  947. x           * is from the terminal at the top level and not
  948. x           * in a loop.
  949. x           */
  950. x!         if (enterhist || catch && intty && !whyles)
  951. x              savehist(¶ml);
  952. x  
  953. x          /*
  954. x
  955. x--- 975,981 -----
  956. x           * is from the terminal at the top level and not
  957. x           * in a loop.
  958. x           */
  959. x!         if (enterhist || catch && intty && !whyles && !tellwhat)
  960. x              savehist(¶ml);
  961. x  
  962. x          /*
  963. x***************
  964. x*** 799,804
  965. x          alias(¶ml);
  966. x  
  967. x          /*
  968. x           * Parse the words of the input into a parse tree.
  969. x           */
  970. x          t = syntax(paraml.next, ¶ml, 0);
  971. x
  972. x--- 995,1008 -----
  973. x          alias(¶ml);
  974. x  
  975. x          /*
  976. x+          * If had a tell_what from twenex() then do
  977. x+          */
  978. x+         if (tellwhat) {
  979. x+             tellmewhat(¶ml);
  980. x+             reset();
  981. x+         }
  982. x+ 
  983. x+         /*
  984. x           * Parse the words of the input into a parse tree.
  985. x           */
  986. x          t = syntax(paraml.next, ¶ml, 0);
  987. x***************
  988. x*** 885,891
  989. x      chktim = t;
  990. x  }
  991. x  
  992. x! #include <pwd.h>
  993. x  /*
  994. x   * Extract a home directory from the password file
  995. x   * The argument points to a buffer where the name of the
  996. x
  997. x--- 1089,1095 -----
  998. x      chktim = t;
  999. x  }
  1000. x  
  1001. x! /* #include <pwd.h> */
  1002. x  /*
  1003. x   * Extract a home directory from the password file
  1004. x   * The argument points to a buffer where the name of the
  1005. x***************
  1006. x*** 919,924
  1007. x      closem();
  1008. x  }
  1009. x  
  1010. x  exit(i)
  1011. x      int i;
  1012. x  {
  1013. x
  1014. x--- 1123,1405 -----
  1015. x      closem();
  1016. x  }
  1017. x  
  1018. x+ /*
  1019. x+  * Karl Kleinpaste, 21oct1983.
  1020. x+  * Added precmd(), which checks for the alias
  1021. x+  * precmd in aliases.  If it's there, the alias
  1022. x+  * is executed as a command.  This is done
  1023. x+  * after mailchk() and just before print-
  1024. x+  * ing the prompt.  Useful for things like printing
  1025. x+  * one's current directory just before each command.
  1026. x+  */
  1027. x+ precmd()
  1028. x+ {
  1029. x+ 
  1030. x+     sighold (SIGINT);
  1031. x+     if (precmd_active) {    /* an error must have been caught */
  1032. x+         aliasrun (2, "unalias", "precmd");
  1033. x+         printf ("Faulty alias 'precmd' removed.\n");
  1034. x+         goto leave;
  1035. x+     }
  1036. x+     precmd_active++;
  1037. x+     if (!whyles && adrof1 ("precmd", &aliases))
  1038. x+         aliasrun (1, "precmd", (char *) 0);
  1039. x+ leave:
  1040. x+     precmd_active = 0;
  1041. x+     sigrelse (SIGINT);
  1042. x+ }
  1043. x+ 
  1044. x+ /*
  1045. x+  * Karl Kleinpaste, 18 Jan 1984.
  1046. x+  * Added period_cmd(), which executes the alias "periodic" every
  1047. x+  * $tperiod minutes.  Useful for occasional checking of msgs and such.
  1048. x+  */
  1049. x+ period_cmd()
  1050. x+ {
  1051. x+     register char *vp;
  1052. x+     time_t t, interval;
  1053. x+ 
  1054. x+     sighold (SIGINT);
  1055. x+     if (periodic_active) {    /* an error must have been caught */
  1056. x+         aliasrun (2, "unalias", "periodic");
  1057. x+         printf ("Faulty alias 'periodic' removed.\n");
  1058. x+         goto leave;
  1059. x+     }
  1060. x+     periodic_active++;
  1061. x+     if (!whyles && adrof1 ("periodic", &aliases)) {
  1062. x+         vp = value ("tperiod");
  1063. x+         if (vp == (char *) 0)
  1064. x+             return;
  1065. x+         interval = getn (vp);
  1066. x+         time (&t);
  1067. x+         if (t - t_period >= interval * 60) {
  1068. x+             t_period = t;
  1069. x+             aliasrun (1, "periodic", (char *) 0);
  1070. x+         }
  1071. x+     }
  1072. x+ leave:
  1073. x+     periodic_active = 0;
  1074. x+     sigrelse (SIGINT);
  1075. x+ }
  1076. x+ 
  1077. x+ /*
  1078. x+  * Karl Kleinpaste, 21oct1983.
  1079. x+  * Set up a one-word alias command, for use for special things.
  1080. x+  * This code is based on the mainline of process().
  1081. x+  */
  1082. x+ aliasrun (cnt, s1, s2)
  1083. x+     int cnt;
  1084. x+     char *s1, *s2;
  1085. x+ {
  1086. x+     struct    wordent    w, *new1, *new2;    /* for holding alias name */
  1087. x+     struct    command    *t = (struct command *) 0;
  1088. x+ 
  1089. x+     err = NOSTR;            /* don't repeatedly print err msg. */
  1090. x+     w.word = "";
  1091. x+     new1 = (struct wordent *) calloc (1, sizeof w);
  1092. x+     new1->word = savestr (s1);
  1093. x+     if (cnt == 1) {
  1094. x+         /* build a lex list with one word. */
  1095. x+         w.next = w.prev = new1;
  1096. x+         new1->next = new1->prev = &w;
  1097. x+     } else {
  1098. x+         /* build a lex list with two words. */
  1099. x+         new2 = (struct wordent *) calloc (1, sizeof w);
  1100. x+         new2->word = savestr (s2);
  1101. x+         w.next = new2->prev = new1;
  1102. x+         new1->next = w.prev = new2;
  1103. x+         new1->prev = new2->next = &w;
  1104. x+     }
  1105. x+ 
  1106. x+     /* expand aliases like process() does. */
  1107. x+     alias (&w);
  1108. x+     /* build a syntax tree for the command. */
  1109. x+     t = syntax (w.next, &w, 0);
  1110. x+     if (err)
  1111. x+         error (err);
  1112. x+     /* execute the parse tree. */
  1113. x+     execute (t, -1);
  1114. x+     /* done. free the lex list and parse tree. */
  1115. x+     freelex (&w), freesyn (t);
  1116. x+ }
  1117. x+ 
  1118. x+ /*
  1119. x+  * Karl Kleinpaste, 26 Jan 1984.
  1120. x+  * Initialize the dummy tty list for login watch.
  1121. x+  * This dummy list eliminates boundary conditions
  1122. x+  * when doing pointer-chase searches.
  1123. x+  */
  1124. x+ initwatch()
  1125. x+ {
  1126. x+     wholist = (struct who *) calloc (1, sizeof *wholist);
  1127. x+     wholist->w_next = (struct who *) calloc (1, sizeof *wholist);
  1128. x+     wholist->w_next->w_prev = wholist;
  1129. x+     strcpy (wholist->w_tty, "\01\01\01\01\01");
  1130. x+     strcpy (wholist->w_next->w_tty, "~~~~~");
  1131. x+ #ifdef WHODEBUG
  1132. x+     debugwholist ((struct who *) 0, (struct who *) 0);
  1133. x+ #endif WHODEBUG
  1134. x+ }
  1135. x+ 
  1136. x+ /*
  1137. x+  * Karl Kleinpaste, 26 Jan 1984.
  1138. x+  * Watch /etc/utmp for login/logout changes.
  1139. x+  */
  1140. x+ watch_login()
  1141. x+ {
  1142. x+     int utmpfd, comparison, alldone, cnt;
  1143. x+     struct utmp utmp;
  1144. x+     struct who *wp, *wpnew;
  1145. x+     struct varent *v;
  1146. x+     char **vp, *cp;
  1147. x+     time_t t, interval;
  1148. x+ 
  1149. x+     /* stop SIGINT, lest our login list get trashed. */
  1150. x+     sighold (SIGINT);
  1151. x+ 
  1152. x+     v = adrof ("watch");
  1153. x+     if (v == (struct varent *) 0) {
  1154. x+         sigrelse (SIGINT);
  1155. x+         return;            /* no names to watch */
  1156. x+     }
  1157. x+     vp = v->vec;
  1158. x+     cnt = blklen (vp);
  1159. x+     if (cnt % 2) {            /* odd # args: 1st == # minutes. */
  1160. x+         interval = (number (*vp)) ? getn (*vp++) : MAILINTVL;
  1161. x+         cnt--;
  1162. x+     }
  1163. x+     time (&t);
  1164. x+     if (t - watch_period < interval * 60) {
  1165. x+         sigrelse (SIGINT);
  1166. x+         return;            /* not long enough yet... */
  1167. x+     }
  1168. x+     watch_period = t;
  1169. x+ 
  1170. x+     if ((utmpfd = open ("/etc/utmp", 0)) < 0) {
  1171. x+         printf ("/etc/utmp cannot be opened.  Please \"unset watch\".\n");
  1172. x+         sigrelse (SIGINT);
  1173. x+         return;
  1174. x+     }
  1175. x+ 
  1176. x+     /*
  1177. x+      * Read in the utmp file, sort the entries, and update existing
  1178. x+      * entries or add new entries to the status list.
  1179. x+      */
  1180. x+     while (read (utmpfd, &utmp, sizeof utmp) == sizeof utmp) {
  1181. x+         if (utmp.ut_name[0] == '\0' && utmp.ut_line[0] == '\0')
  1182. x+             continue;    /* completely void entry */
  1183. x+         wp = wholist;
  1184. x+         while ((comparison = strncmp (wp->w_tty, utmp.ut_line, 8)) < 0)
  1185. x+             wp = wp->w_next;    /* find that tty! */
  1186. x+ 
  1187. x+         if (comparison == 0) {        /* found the tty... */
  1188. x+             if (utmp.ut_name[0] == '\0')
  1189. x+                 wp->w_status = OFFLINE;
  1190. x+             else            /* someone is logged in */
  1191. x+                 if (strncmp (utmp.ut_name, wp->w_name, 8) == 0)
  1192. x+                     wp->w_status = 0;    /* same guy */
  1193. x+                 else {
  1194. x+                     strncpy (wp->w_new, utmp.ut_name, 8);
  1195. x+                     if (wp->w_name[0] == '\0')
  1196. x+                         wp->w_status = ONLINE;
  1197. x+                     else
  1198. x+                         wp->w_status = CHANGED;
  1199. x+                 }
  1200. x+         } else {            /* new tty in utmp */
  1201. x+             wpnew = (struct who *) calloc (1, sizeof *wpnew);
  1202. x+             strncpy (wpnew->w_tty, utmp.ut_line, 8);
  1203. x+             if (utmp.ut_name[0] == '\0')
  1204. x+                 wpnew->w_status = OFFLINE;
  1205. x+             else {
  1206. x+                 strncpy (wpnew->w_new, utmp.ut_name, 8);
  1207. x+                 wpnew->w_status = ONLINE;
  1208. x+             }
  1209. x+ #ifdef WHODEBUG
  1210. x+             debugwholist(wpnew, wp);
  1211. x+ #endif WHODEBUG
  1212. x+ 
  1213. x+             wpnew->w_next = wp;    /* link in a new 'who' */
  1214. x+             wpnew->w_prev = wp->w_prev;
  1215. x+             wpnew->w_prev->w_next = wpnew;
  1216. x+             wp->w_prev = wpnew;    /* linked in now */
  1217. x+         }
  1218. x+     }
  1219. x+     close (utmpfd);
  1220. x+ 
  1221. x+     /*
  1222. x+      * The state of all logins is now known, so we can search
  1223. x+      * the user's list of watchables to print the interesting ones.
  1224. x+      */
  1225. x+     for (alldone = 0; !alldone && *vp != (char *) 0 && **vp != '\0' &&
  1226. x+             *(vp+1) != (char *) 0 && **(vp+1) != '\0';
  1227. x+             vp += 2) {        /* args used in pairs... */
  1228. x+ 
  1229. x+         if (eq (*vp, "any") && eq (*(vp+1), "any"))
  1230. x+             alldone++;
  1231. x+ 
  1232. x+         for (wp = wholist; wp != (struct who *) 0; wp = wp->w_next) {
  1233. x+             if (wp->w_status & ANNOUNCE        ||
  1234. x+                 (!eq (*vp, "any") && !eq (*vp, wp->w_name) &&
  1235. x+                 !eq (*vp, wp->w_new))        ||
  1236. x+                 (!eq (*(vp+1), wp->w_tty) && !eq (*(vp+1), "any")))
  1237. x+                 continue;    /* entry doesn't qualify */
  1238. x+                 /* already printed or not right one to print */
  1239. x+ 
  1240. x+             if ((wp->w_status & OFFLINE) &&
  1241. x+                 (wp->w_name[0] != '\0')) {
  1242. x+                 printf ("%s has logged off %s.\n",
  1243. x+                     wp->w_name, wp->w_tty);
  1244. x+                 wp->w_name[0] = '\0';
  1245. x+                 wp->w_status |= ANNOUNCE;
  1246. x+                 continue;
  1247. x+             }
  1248. x+             if (wp->w_status & ONLINE) {
  1249. x+                 printf ("%s has logged on %s.\n",
  1250. x+                     wp->w_new, wp->w_tty);
  1251. x+                 strcpy (wp->w_name, wp->w_new);
  1252. x+                 wp->w_status |= ANNOUNCE;
  1253. x+                 continue;
  1254. x+             }
  1255. x+             if (wp->w_status & CHANGED) {
  1256. x+                 printf ("%s has replaced %s on %s.\n",
  1257. x+                     wp->w_new, wp->w_name, wp->w_tty);
  1258. x+                 strcpy (wp->w_name, wp->w_new);
  1259. x+                 wp->w_status |= ANNOUNCE;
  1260. x+                 continue;
  1261. x+             }
  1262. x+         }
  1263. x+     }
  1264. x+     sigrelse (SIGINT);
  1265. x+ }
  1266. x+ 
  1267. x+ #ifdef WHODEBUG
  1268. x+ debugwholist (new, wp)
  1269. x+ register struct who *new, *wp;
  1270. x+ {
  1271. x+     register struct who *a;
  1272. x+ 
  1273. x+     a = wholist;
  1274. x+     while (a != (struct who *) 0) {
  1275. x+         printf ("%s/%s -> ", a->w_name, a->w_tty);
  1276. x+         a = a->w_next;
  1277. x+     }
  1278. x+     printf ("NULL\n");
  1279. x+     a = wholist;
  1280. x+     printf ("backward: ");
  1281. x+     while (a->w_next != (struct who *) 0)
  1282. x+         a = a->w_next;
  1283. x+     while (a != (struct who *) 0) {
  1284. x+         printf ("%s/%s -> ", a->w_name, a->w_tty);
  1285. x+         a = a->w_prev;
  1286. x+     }
  1287. x+     printf ("NULL\n");
  1288. x+     if (new)
  1289. x+         printf ("new: %s/%s\n", new->w_name, new->w_tty);
  1290. x+     if (wp)
  1291. x+         printf ("wp: %s/%s\n", wp->w_name, wp->w_tty);
  1292. x+ }
  1293. x+ #endif WHODEBUG
  1294. x+ 
  1295. x  exit(i)
  1296. x      int i;
  1297. x  {
  1298. x***************
  1299. x*** 929,932
  1300. x  #else
  1301. x      _exit(i);
  1302. x  #endif
  1303. x  }
  1304. x
  1305. x--- 1410,1531 -----
  1306. x  #else
  1307. x      _exit(i);
  1308. x  #endif
  1309. x+ }
  1310. x+ 
  1311. x+ 
  1312. x+ /*
  1313. x+  * kfk 21oct1983 -- add @ (time) and / ($cwd) in prompt.
  1314. x+  * PWP 4/27/87 -- rearange for tcsh.
  1315. x+  */
  1316. x+ 
  1317. x+ printprompt ()
  1318. x+ {
  1319. x+     register char *cp, *p, *z;
  1320. x+     register char underlining = 0;
  1321. x+     extern char *value ();
  1322. x+ 
  1323. x+     PromptBuf[0] = '\0';
  1324. x+     p = PromptBuf;
  1325. x+     if (whyles)
  1326. x+     cp = value("prompt2");
  1327. x+     else
  1328. x+     cp = value("prompt");
  1329. x+ 
  1330. x+     for (; *cp; cp++) {
  1331. x+     if (*cp == '%') {
  1332. x+         cp++;
  1333. x+         if (*cp == HIST || *cp == 'h') {
  1334. x+         itoa(eventno + 1, buff);
  1335. x+         for (z = buff; *z; z++)
  1336. x+             *p++ = underlining | *z;
  1337. x+         } else if (*cp == '@' || *cp == 't') {
  1338. x+         struct tm *t;
  1339. x+         long clock;
  1340. x+         char ampm = 'a';
  1341. x+ 
  1342. x+         time (&clock);
  1343. x+         t = localtime(&clock);
  1344. x+         if (t->tm_hour >= 12) {
  1345. x+             if (t->tm_hour > 12)
  1346. x+             t->tm_hour -= 12;
  1347. x+             ampm = 'p';
  1348. x+         } else if (t->tm_hour == 0)
  1349. x+             t->tm_hour = 12;
  1350. x+         
  1351. x+         itoa(t->tm_hour, buff);
  1352. x+         *p++ = underlining | buff[0];
  1353. x+         if (buff[1]) *p++ = underlining | buff[1];
  1354. x+         *p++ = underlining | ':';
  1355. x+         itoa(t->tm_min, buff);
  1356. x+         if (buff[1]) {
  1357. x+             *p++ = underlining | buff[0];
  1358. x+             *p++ = underlining | buff[1];
  1359. x+         } else {
  1360. x+             *p++ = underlining | '0';
  1361. x+             *p++ = underlining | buff[0];
  1362. x+         }
  1363. x+         *p++ = underlining | ampm;
  1364. x+         *p++ = underlining | 'm';
  1365. x+         } else if (*cp == 'M') {
  1366. x+         for (z = getenv("HOST"); *z; z++)
  1367. x+             *p++ = underlining | *z;
  1368. x+         } else if (*cp == 'm') {
  1369. x+         for (z = getenv("HOST"); *z && *z != '.'; z++)
  1370. x+             *p++ = underlining | *z;
  1371. x+         } else if (*cp == '/' || *cp == 'd') {
  1372. x+         for (z = value("cwd"); *z; z++)
  1373. x+             *p++ = underlining | *z;
  1374. x+         } else if (*cp == '.' || *cp == 'c') {
  1375. x+         strcpy (buff, value("cwd"));
  1376. x+         if (!buff[1]) {    /* if CWD == / */
  1377. x+             *p++ = underlining | buff[0];
  1378. x+         } else {
  1379. x+             if (strcmp(buff, value("home")) == 0) {
  1380. x+             *p++ = underlining | '~';
  1381. x+             } else {
  1382. x+             for (z = buff; *z; z++) ; /* find the end */
  1383. x+             while ((z > buff) && (*z != '/')) z--; /* back up */
  1384. x+             if (*z == '/') z++;
  1385. x+             while (*z)
  1386. x+                 *p++ = underlining | *z++;
  1387. x+             }
  1388. x+         }
  1389. x+ 
  1390. x+         } else if (*cp == 'S' || *cp == 'U') { /* start standout */
  1391. x+         underlining = 0200;
  1392. x+         } else if (*cp == 's' || *cp == 'u') { /* end standout */
  1393. x+         underlining = 0;
  1394. x+         } else if (*cp == '%') {
  1395. x+         *p++ = underlining | '%';
  1396. x+         } else {
  1397. x+         *p++ = underlining | '%';
  1398. x+         *p++ = underlining | *cp;
  1399. x+         }
  1400. x+     } else {
  1401. x+         *p++ = underlining | *cp;        /* normal character */
  1402. x+     }
  1403. x+     }
  1404. x+     *p = '\0';
  1405. x+ }
  1406. x+ 
  1407. x+ setalarm()
  1408. x+ {
  1409. x+     struct varent *vp;
  1410. x+     char *cp;
  1411. x+     int alrm_time = 0;
  1412. x+     long cl, sched_dif;
  1413. x+     extern    struct    sched_event *sched_ptr;
  1414. x+ 
  1415. x+     if (vp = adrof("autologout"))
  1416. x+     {
  1417. x+         if (cp = vp->vec[0])
  1418. x+             alrm_time = (atoi (cp) * 60);
  1419. x+     }
  1420. x+     if (sched_ptr) {
  1421. x+         time(&cl);
  1422. x+         sched_dif = sched_ptr->t_when - cl;
  1423. x+         if ((alrm_time == 0) || (sched_dif < alrm_time))
  1424. x+             alrm_time = ((int) sched_dif) + 1;
  1425. x+     }
  1426. x+     alarm (alrm_time);    /* Autologout ON */
  1427. x  }
  1428. x*** ../csh4.2/sh.dir.c    Tue Jun 23 12:13:45 1987
  1429. x--- sh.dir.c    Sun Jun 28 23:19:59 1987
  1430. x***************
  1431. x*** 203,208
  1432. x      } else if (dp = dfind(*v)) {
  1433. x          if (chdir(dp->di_name) < 0)
  1434. x              Perror(dp->di_name);
  1435. x      } else {
  1436. x          register char *cp;
  1437. x  
  1438. x
  1439. x--- 203,213 -----
  1440. x      } else if (dp = dfind(*v)) {
  1441. x          if (chdir(dp->di_name) < 0)
  1442. x              Perror(dp->di_name);
  1443. x+         /*
  1444. x+          * kfk - 10 Feb 1984 - added new "extraction style" pushd +n
  1445. x+          */
  1446. x+         if (adrof ("dextract"))
  1447. x+             dextract (dp);
  1448. x      } else {
  1449. x          register char *cp;
  1450. x  
  1451. x***************
  1452. x*** 356,359
  1453. x      set("cwd", savestr(dcwd->di_name));
  1454. x      if (printd)
  1455. x          dodirs(fakev);
  1456. x  }
  1457. x
  1458. x--- 361,416 -----
  1459. x      set("cwd", savestr(dcwd->di_name));
  1460. x      if (printd)
  1461. x          dodirs(fakev);
  1462. x+ }
  1463. x+ 
  1464. x+ /*
  1465. x+  * getstakd - added by kfk 17 Jan 1984
  1466. x+  * Support routine for the stack hack.  Finds nth directory in
  1467. x+  * the directory stack, or finds last directory in stack.
  1468. x+  */
  1469. x+ getstakd (s, cnt, callerr)
  1470. x+     char *s;
  1471. x+     int cnt, callerr;
  1472. x+ {
  1473. x+     struct directory *dp;
  1474. x+ 
  1475. x+     dp = dcwd;
  1476. x+     if (cnt < 0) {        /* < 0 ==> last dir requested. */
  1477. x+         dp = dp->di_next;
  1478. x+         if (dp == &dhead)
  1479. x+             dp = dp->di_next;
  1480. x+     } else {
  1481. x+         while (cnt-- > 0) {
  1482. x+             dp = dp->di_prev;
  1483. x+             if (dp == &dhead)
  1484. x+                 dp = dp->di_prev;
  1485. x+             if (dp == dcwd) {
  1486. x+                 if (callerr)
  1487. x+                     error ("Not that many dir stack entries");
  1488. x+                 else
  1489. x+                     return;
  1490. x+             }
  1491. x+         }
  1492. x+     }
  1493. x+     strcpy (s, dp->di_name);
  1494. x+ }
  1495. x+ 
  1496. x+ /*
  1497. x+  * Karl Kleinpaste - 10 Feb 1984
  1498. x+  * Added dextract(), which is used in pushd +n.
  1499. x+  * Instead of just rotating the entire stack around, dextract()
  1500. x+  * lets the user have the nth dir extracted from its current
  1501. x+  * position, and pushes it onto the top.
  1502. x+  */
  1503. x+ dextract(dp)
  1504. x+ struct directory *dp;
  1505. x+ {
  1506. x+     if (dp == dcwd)
  1507. x+         return;
  1508. x+     dp->di_next->di_prev = dp->di_prev;
  1509. x+     dp->di_prev->di_next = dp->di_next;
  1510. x+     dp->di_next = dcwd->di_next;
  1511. x+     dp->di_prev = dcwd;
  1512. x+     dp->di_next->di_prev = dp;
  1513. x+     dcwd->di_next = dp;
  1514. x  }
  1515. xNo differences encountered
  1516. xNo differences encountered
  1517. x*** ../csh4.2/sh.err.c    Tue Jun 23 12:13:46 1987
  1518. x--- sh.err.c    Mon Jun 29 17:33:04 1987
  1519. x***************
  1520. x*** 1,7
  1521. x  static    char *sccsid = "@(#)sh.err.c 4.1 10/9/80";
  1522. x  
  1523. x  #include "sh.h"
  1524. x! #include <sys/ioctl.h>
  1525. x  
  1526. x  /*
  1527. x   * C Shell
  1528. x
  1529. x--- 1,7 -----
  1530. x  static    char *sccsid = "@(#)sh.err.c 4.1 10/9/80";
  1531. x  
  1532. x  #include "sh.h"
  1533. x! /* #include <sys/ioctl.h> */
  1534. x  
  1535. x  /*
  1536. x   * C Shell
  1537. x***************
  1538. x*** 69,74
  1539. x          exit(1);
  1540. x  
  1541. x      setq("status", onev, &shvhed);
  1542. x      if (tpgrp > 0)
  1543. x          ioctl(FSHTTY, TIOCSPGRP, &tpgrp);
  1544. x      reset();        /* Unwind */
  1545. x
  1546. x--- 69,75 -----
  1547. x          exit(1);
  1548. x  
  1549. x      setq("status", onev, &shvhed);
  1550. x+ #ifdef BSDJOBS
  1551. x      if (tpgrp > 0)
  1552. x          ioctl(FSHTTY, TIOCSPGRP, &tpgrp);
  1553. x  #endif
  1554. x***************
  1555. x*** 71,76
  1556. x      setq("status", onev, &shvhed);
  1557. x      if (tpgrp > 0)
  1558. x          ioctl(FSHTTY, TIOCSPGRP, &tpgrp);
  1559. x      reset();        /* Unwind */
  1560. x  }
  1561. x  
  1562. x
  1563. x--- 72,78 -----
  1564. x  #ifdef BSDJOBS
  1565. x      if (tpgrp > 0)
  1566. x          ioctl(FSHTTY, TIOCSPGRP, &tpgrp);
  1567. x+ #endif
  1568. x      reset();        /* Unwind */
  1569. x  }
  1570. x  
  1571. x*** ../csh4.2/sh.exec.c    Tue Jun 23 12:13:46 1987
  1572. x--- sh.exec.c    Sun Jun 28 23:20:06 1987
  1573. x***************
  1574. x*** 1,7
  1575. x  static    char *sccsid = "@(#)sh.exec.c 4.8 7/1/83";
  1576. x  
  1577. x  #include "sh.h"
  1578. x! #include <sys/dir.h>
  1579. x  
  1580. x  /*
  1581. x   * C shell
  1582. x
  1583. x--- 1,7 -----
  1584. x  static    char *sccsid = "@(#)sh.exec.c 4.8 7/1/83";
  1585. x  
  1586. x  #include "sh.h"
  1587. x! /* #include <sys/dir.h> */
  1588. x  
  1589. x  /*
  1590. x   * C shell
  1591. x***************
  1592. x*** 226,231
  1593. x  }
  1594. x  
  1595. x  execash(t, kp)
  1596. x      register struct command *kp;
  1597. x  {
  1598. x  
  1599. x
  1600. x--- 226,232 -----
  1601. x  }
  1602. x  
  1603. x  execash(t, kp)
  1604. x+     char *t;
  1605. x      register struct command *kp;
  1606. x  {
  1607. x  
  1608. x***************
  1609. x*** 262,267
  1610. x      struct varent *v = adrof("path");
  1611. x      char **pv;
  1612. x  
  1613. x      havhash = 1;
  1614. x      for (cnt = 0; cnt < HSHSIZ; cnt++)
  1615. x          xhash[cnt] = 0;
  1616. x
  1617. x--- 263,269 -----
  1618. x      struct varent *v = adrof("path");
  1619. x      char **pv;
  1620. x  
  1621. x+     tw_clear_comm_list();
  1622. x      havhash = 1;
  1623. x      for (cnt = 0; cnt < HSHSIZ; cnt++)
  1624. x          xhash[cnt] = 0;
  1625. x***************
  1626. x*** 273,278
  1627. x          dirp = opendir(*pv);
  1628. x          if (dirp == NULL)
  1629. x              continue;
  1630. x          if (fstat(dirp->dd_fd, &stb) < 0 || !isdir(stb)) {
  1631. x              closedir(dirp);
  1632. x              continue;
  1633. x
  1634. x--- 275,281 -----
  1635. x          dirp = opendir(*pv);
  1636. x          if (dirp == NULL)
  1637. x              continue;
  1638. x+ #ifdef COMMENT    /* this isn't needed.  opendir won't open non-dirs */
  1639. x          if (fstat(dirp->dd_fd, &stb) < 0 || !isdir(stb)) {
  1640. x              closedir(dirp);
  1641. x              continue;
  1642. x***************
  1643. x*** 277,282
  1644. x              closedir(dirp);
  1645. x              continue;
  1646. x          }
  1647. x          while ((dp = readdir(dirp)) != NULL) {
  1648. x              if (dp->d_ino == 0)
  1649. x                  continue;
  1650. x
  1651. x--- 280,286 -----
  1652. x              closedir(dirp);
  1653. x              continue;
  1654. x          }
  1655. x+ #endif
  1656. x          while ((dp = readdir(dirp)) != NULL) {
  1657. x              if (dp->d_ino == 0)
  1658. x                  continue;
  1659. x***************
  1660. x*** 281,286
  1661. x              if (dp->d_ino == 0)
  1662. x                  continue;
  1663. x              xhash[hash(dp->d_name)] |= (1 << i);
  1664. x          }
  1665. x          closedir(dirp);
  1666. x      }
  1667. x
  1668. x--- 285,291 -----
  1669. x              if (dp->d_ino == 0)
  1670. x                  continue;
  1671. x              xhash[hash(dp->d_name)] |= (1 << i);
  1672. x+             /* tw_add_comm_name (dp->d_name); */
  1673. x          }
  1674. x          closedir(dirp);
  1675. x      }
  1676. x***************
  1677. x*** 313,316
  1678. x          hash = -hash;
  1679. x      retval = hash % HSHSIZ;
  1680. x      return (retval);
  1681. x  }
  1682. x
  1683. x--- 318,414 -----
  1684. x          hash = -hash;
  1685. x      retval = hash % HSHSIZ;
  1686. x      return (retval);
  1687. x+ }
  1688. x+ 
  1689. x+ int
  1690. x+ iscommand(name)
  1691. x+     char *name;
  1692. x+ {
  1693. x+     char *sav;
  1694. x+     register char *dp, **pv;
  1695. x+     register struct varent *v;
  1696. x+     bool slash = any('/', name);
  1697. x+     int hashval, i;
  1698. x+ 
  1699. x+     v = adrof("path");
  1700. x+     if (v == 0 || v->vec[0] == 0 || slash)
  1701. x+         pv = justabs;
  1702. x+     else
  1703. x+         pv = v->vec;
  1704. x+     sav = strspl("/", name);        /* / command name for postpending */
  1705. x+     if (havhash)
  1706. x+         hashval = xhash[hash(name)];
  1707. x+     i = 0;
  1708. x+     do {
  1709. x+         if (!slash && pv[0][0] == '/' && havhash && (hashval & (1 << (i % 8))) == 0)
  1710. x+             goto cont;
  1711. x+         if (pv[0][0] == 0 || eq(pv[0], ".")) {    /* don't make ./xxx */
  1712. x+             if (access(name, 1) == 0) {
  1713. x+                 xfree(sav);
  1714. x+                 return i+1;
  1715. x+             }
  1716. x+         } else {
  1717. x+             dp = strspl(*pv, sav);
  1718. x+             if (access(dp, 1) == 0) {
  1719. x+                 xfree(sav);
  1720. x+                 xfree(dp);
  1721. x+                 return i+1;
  1722. x+             }
  1723. x+             xfree(dp);
  1724. x+         }
  1725. x+ cont:
  1726. x+         pv++;
  1727. x+         i++;
  1728. x+     } while (*pv);
  1729. x+     xfree(sav);
  1730. x+     return 0;
  1731. x+ }
  1732. x+ 
  1733. x+ tellmewhat(lex)
  1734. x+     struct wordent *lex;
  1735. x+ {
  1736. x+     register char *cp;
  1737. x+     register int i;
  1738. x+     register struct biltins *bptr;
  1739. x+     register struct wordent *sp = lex->next;
  1740. x+ 
  1741. x+ 
  1742. x+     for (bptr = bfunc; cp = bptr->bname; bptr++) {
  1743. x+     if (strcmp(sp->word, cp) == 0) {
  1744. x+         prlex(lex);
  1745. x+         printf("%s: is built in.\n", sp->word);
  1746. x+         flush();
  1747. x+         return;
  1748. x+     }
  1749. x+     }
  1750. x+ 
  1751. x+     while (*(sp->word) & 0200) (sp->word)++;
  1752. x+     if (i = iscommand(strip(sp->word))) {
  1753. x+     char *s1;
  1754. x+     register char **pv;
  1755. x+     register struct varent *v;
  1756. x+     bool slash = any('/', sp->word);
  1757. x+ 
  1758. x+     v = adrof("path");
  1759. x+     if (v == 0 || v->vec[0] == 0 || slash)
  1760. x+         pv = justabs;
  1761. x+     else
  1762. x+         pv = v->vec;
  1763. x+ 
  1764. x+     while (--i) pv++;
  1765. x+     if (pv[0][0] == 0 || eq(pv[0], ".")) {
  1766. x+         prlex(lex);
  1767. x+         return;
  1768. x+     }
  1769. x+     s1 = strspl(*pv, "/");
  1770. x+     sp->word = strspl(s1, sp->word);
  1771. x+     xfree(s1);
  1772. x+     prlex(lex);
  1773. x+     xfree(sp->word);
  1774. x+     sp->word = (char *)0;
  1775. x+     } else {
  1776. x+     prlex(lex);
  1777. x+     printf("%s: Command not found.\n", sp->word);
  1778. x+     flush();
  1779. x+     }
  1780. x  }
  1781. xNo differences encountered
  1782. x*** ../csh4.2/sh.func.c    Tue Jun 23 12:13:48 1987
  1783. x--- sh.func.c    Thu Jul 16 14:01:54 1987
  1784. x***************
  1785. x*** 1,7
  1786. x  static    char *sccsid = "@(#)sh.func.c 4.10 83/06/11";
  1787. x  
  1788. x  #include "sh.h"
  1789. x! #include <sys/ioctl.h>
  1790. x  
  1791. x  /*
  1792. x   * C shell
  1793. x
  1794. x--- 1,7 -----
  1795. x  static    char *sccsid = "@(#)sh.func.c 4.10 83/06/11";
  1796. x  
  1797. x  #include "sh.h"
  1798. x! /* #include <sys/ioctl.h> */
  1799. x  
  1800. x  /*
  1801. x   * C shell
  1802. x***************
  1803. x*** 157,163
  1804. x      islogin();
  1805. x      rechist();
  1806. x      signal(SIGTERM, parterm);
  1807. x!     execl("/bin/login", "login", v[1], 0);
  1808. x      untty();
  1809. x      exit(1);
  1810. x  }
  1811. x
  1812. x--- 157,163 -----
  1813. x      islogin();
  1814. x      rechist();
  1815. x      signal(SIGTERM, parterm);
  1816. x!     execl("/bin/login", "login", v[1], (char *) 0);
  1817. x      untty();
  1818. x      exit(1);
  1819. x  }
  1820. x***************
  1821. x*** 162,167
  1822. x      exit(1);
  1823. x  }
  1824. x  
  1825. x  #ifdef NEWGRP
  1826. x  donewgrp(v)
  1827. x      char **v;
  1828. x
  1829. x--- 162,186 -----
  1830. x      exit(1);
  1831. x  }
  1832. x  
  1833. x+ dolog()
  1834. x+ {
  1835. x+     extern struct who *wholist;
  1836. x+     extern time_t watch_period;
  1837. x+     struct who *wp;
  1838. x+     struct varent *v;
  1839. x+ 
  1840. x+     if ((v = adrof ("watch")) == (struct varent *) 0)
  1841. x+         error ("No $watch variable set");
  1842. x+     blkpr (v->vec);
  1843. x+     printf ("\n");
  1844. x+     watch_period = 0;
  1845. x+     wp = wholist;
  1846. x+     while (wp != (struct who *) 0) {
  1847. x+         wp->w_name[0] = '\0';
  1848. x+         wp = wp->w_next;
  1849. x+     }
  1850. x+ }
  1851. x+ 
  1852. x  #ifdef NEWGRP
  1853. x  donewgrp(v)
  1854. x      char **v;
  1855. x***************
  1856. x*** 170,177
  1857. x      if (chkstop == 0 && setintr)
  1858. x          panystop(0);
  1859. x      signal(SIGTERM, parterm);
  1860. x!     execl("/bin/newgrp", "newgrp", v[1], 0);
  1861. x!     execl("/usr/bin/newgrp", "newgrp", v[1], 0);
  1862. x      untty();
  1863. x      exit(1);
  1864. x  }
  1865. x
  1866. x--- 189,196 -----
  1867. x      if (chkstop == 0 && setintr)
  1868. x          panystop(0);
  1869. x      signal(SIGTERM, parterm);
  1870. x!     execl("/bin/newgrp", "newgrp", v[1], (char *) 0);
  1871. x!     execl("/usr/bin/newgrp", "newgrp", v[1], (char *) 0);
  1872. x      untty();
  1873. x      exit(1);
  1874. x  }
  1875. x***************
  1876. x*** 501,507
  1877. x          bseek(0l);
  1878. x      do {
  1879. x          if (intty && fseekp == feobp)
  1880. x!             printf("? "), flush();
  1881. x          aword[0] = 0, getword(aword);
  1882. x          switch (srchx(aword)) {
  1883. x  
  1884. x
  1885. x--- 520,526 -----
  1886. x          bseek(0l);
  1887. x      do {
  1888. x          if (intty && fseekp == feobp)
  1889. x!             printprompt(); /* printf("? "), flush(); */
  1890. x          aword[0] = 0, getword(aword);
  1891. x          switch (srchx(aword)) {
  1892. x  
  1893. x***************
  1894. x*** 822,828
  1895. x      umask(i);
  1896. x  }
  1897. x  
  1898. x! 
  1899. x  struct limits {
  1900. x      int    limconst;
  1901. x      char    *limname;
  1902. x
  1903. x--- 841,847 -----
  1904. x      umask(i);
  1905. x  }
  1906. x  
  1907. x! #ifndef OREO
  1908. x  struct limits {
  1909. x      int    limconst;
  1910. x      char    *limname;
  1911. x***************
  1912. x*** 999,1004
  1913. x      if (setrlimit(lp->limconst, &rlim) < 0)
  1914. x          Perror(bname);
  1915. x  }
  1916. x  
  1917. x  dosuspend()
  1918. x  {
  1919. x
  1920. x--- 1018,1024 -----
  1921. x      if (setrlimit(lp->limconst, &rlim) < 0)
  1922. x          Perror(bname);
  1923. x  }
  1924. x+ #endif OREO
  1925. x  
  1926. x  #ifdef SVID
  1927. x  extern struct termio termiob;
  1928. x***************
  1929. x*** 1000,1005
  1930. x          Perror(bname);
  1931. x  }
  1932. x  
  1933. x  dosuspend()
  1934. x  {
  1935. x      int (*old)(), ldisc;
  1936. x
  1937. x--- 1020,1029 -----
  1938. x  }
  1939. x  #endif OREO
  1940. x  
  1941. x+ #ifdef SVID
  1942. x+ extern struct termio termiob;
  1943. x+ #endif SVID
  1944. x+ 
  1945. x  dosuspend()
  1946. x  {
  1947. x      int (*old)(), ldisc;
  1948. x***************
  1949. x*** 1012,1017
  1950. x      kill(0, SIGTSTP);
  1951. x      /* the shell stops here */
  1952. x      sigsys(SIGTSTP, old);
  1953. x      if (tpgrp != -1) {
  1954. x  retry:
  1955. x          ioctl(FSHTTY, TIOCGPGRP, &ctpgrp);
  1956. x
  1957. x--- 1036,1042 -----
  1958. x      kill(0, SIGTSTP);
  1959. x      /* the shell stops here */
  1960. x      sigsys(SIGTSTP, old);
  1961. x+ #ifdef BSDJOBS
  1962. x      if (tpgrp != -1) {
  1963. x  retry:
  1964. x          ioctl(FSHTTY, TIOCGPGRP, &ctpgrp);
  1965. x***************
  1966. x*** 1024,1029
  1967. x          ioctl(FSHTTY, TIOCSPGRP, &shpgrp);
  1968. x          setpgrp(0, shpgrp);
  1969. x      }
  1970. x      ioctl(FSHTTY, TIOCGETD, &oldisc);
  1971. x      if (oldisc != NTTYDISC) {
  1972. x          printf("Switching to new tty driver...\n");
  1973. x
  1974. x--- 1049,1066 -----
  1975. x          ioctl(FSHTTY, TIOCSPGRP, &shpgrp);
  1976. x          setpgrp(0, shpgrp);
  1977. x      }
  1978. x+ #endif BSDJOBS
  1979. x+ 
  1980. x+ #ifdef SVID
  1981. x+     ioctl(FSHTTY, TCGETA, &termiob);
  1982. x+     if (termiob.c_cc[VSWTCH] != CSWTCH) {
  1983. x+ #ifdef DEBUG
  1984. x+         printf ("Setting ^Z...\n");
  1985. x+ #endif DEBUG
  1986. x+         termiob.c_cc[VSWTCH] = CSWTCH;
  1987. x+         ioctl(FSHTTY, TCSETA, &termiob);
  1988. x+     }
  1989. x+ #else SVID
  1990. x      ioctl(FSHTTY, TIOCGETD, &oldisc);
  1991. x      if (oldisc != NTTYDISC) {
  1992. x          printf("Switching to new tty driver...\n");
  1993. x***************
  1994. x*** 1030,1035
  1995. x          ldisc = NTTYDISC;
  1996. x          ioctl(FSHTTY, TIOCSETD, &ldisc);
  1997. x      }
  1998. x  }
  1999. x  
  2000. x  doeval(v)
  2001. x
  2002. x--- 1067,1073 -----
  2003. x          ldisc = NTTYDISC;
  2004. x          ioctl(FSHTTY, TIOCSETD, &ldisc);
  2005. x      }
  2006. x+ #endif SVID
  2007. x  }
  2008. x  
  2009. x  doeval(v)
  2010. x***************
  2011. x*** 1071,1073
  2012. x      if (reenter >= 2)
  2013. x          error(NOSTR);
  2014. x  }
  2015. x
  2016. x--- 1109,1289 -----
  2017. x      if (reenter >= 2)
  2018. x          error(NOSTR);
  2019. x  }
  2020. x+ 
  2021. x+ /*
  2022. x+  * kfk - added scheduled event functions
  2023. x+  */
  2024. x+ struct sched_event *sched_ptr;
  2025. x+ 
  2026. x+ dosched(v)
  2027. x+     register char **v;
  2028. x+ {
  2029. x+     register struct sched_event *tp, *tp1, *tp2;
  2030. x+     long cur_time;
  2031. x+     int count, hours, minutes, dif_hour, dif_min;
  2032. x+     char *cp;
  2033. x+     bool relative;        /* time specified as +hh:mm */
  2034. x+     struct tm *ltp;
  2035. x+     char *timeline;
  2036. x+     char *ctime();
  2037. x+ 
  2038. x+     v++;
  2039. x+     cp = *v++;
  2040. x+     if (cp == (char *) 0) {
  2041. x+         /* print list of scheduled events */
  2042. x+         for (count = 1, tp = sched_ptr; tp; count++, tp = tp->t_next) {
  2043. x+             timeline = ctime(&tp->t_when);
  2044. x+             timeline[16] = '\0';
  2045. x+             printf ("%6d\t%s\t", count, timeline);
  2046. x+             blkpr (tp->t_lex);
  2047. x+             printf ("\n");
  2048. x+         }
  2049. x+         return;
  2050. x+     }
  2051. x+ 
  2052. x+     if (*cp == '-') {
  2053. x+         /* remove item from list */
  2054. x+         if (!sched_ptr)
  2055. x+             error ("No scheduled events");
  2056. x+         if (*v)
  2057. x+             error ("Too many args for 'sched -<item#>'");
  2058. x+         count = atoi (++cp);
  2059. x+         if (count <= 0)
  2060. x+             error ("Usage to delete: sched -<item#>");
  2061. x+         tp = sched_ptr;
  2062. x+         tp1 = 0;
  2063. x+         while (--count) {
  2064. x+             if (tp->t_next == 0)
  2065. x+                 break;
  2066. x+             else {
  2067. x+                 tp1 = tp;
  2068. x+                 tp = tp->t_next;
  2069. x+             }
  2070. x+         }
  2071. x+         if (count)
  2072. x+             error ("Not that many scheduled events");
  2073. x+         if (tp1 == 0)
  2074. x+             sched_ptr = tp->t_next;
  2075. x+         else
  2076. x+             tp1->t_next = tp->t_next;
  2077. x+         blkfree (tp->t_lex);
  2078. x+         xfree ((char *) tp);
  2079. x+         return;
  2080. x+     }
  2081. x+ 
  2082. x+     /* else, add an item to the list */
  2083. x+     if (!*v)
  2084. x+         error ("No command to run");
  2085. x+     relative = 0;
  2086. x+     if (!digit(*cp)) {        /* not abs. time */
  2087. x+         if (*cp != '+')
  2088. x+             error ("Usage: sched [+]hh:mm <command>");
  2089. x+         cp++, relative++;
  2090. x+     }
  2091. x+     minutes = 0;
  2092. x+     hours = atoi(cp);
  2093. x+     while (*cp && *cp != ':' && *cp != 'a' && *cp != 'p')
  2094. x+         cp++;
  2095. x+     if (*cp && *cp == ':')
  2096. x+         minutes = atoi(++cp);
  2097. x+     if ((hours < 0) || (minutes < 0) ||
  2098. x+         (hours > 23) || (minutes > 59))
  2099. x+         error ("Invalid time for event");
  2100. x+     while (*cp && *cp != 'p' && *cp != 'a')
  2101. x+         cp++;
  2102. x+     if (*cp && relative)
  2103. x+         error ("Relative time inconsistent with am/pm");
  2104. x+     if (*cp == 'p')
  2105. x+         hours += 12;
  2106. x+     time(&cur_time);
  2107. x+     ltp = localtime(&cur_time);
  2108. x+     if (relative) {
  2109. x+         dif_hour = hours;
  2110. x+         dif_min = minutes;
  2111. x+     } else {
  2112. x+         if ((dif_hour = hours - ltp->tm_hour) < 0)
  2113. x+             dif_hour += 24;
  2114. x+         if ((dif_min = minutes - ltp->tm_min) < 0) {
  2115. x+             dif_min += 60;
  2116. x+             if ((--dif_hour) < 0)
  2117. x+                 dif_hour = 23;
  2118. x+         }
  2119. x+     }
  2120. x+     tp = (struct sched_event *) calloc (1, sizeof *tp);
  2121. x+     tp->t_when = cur_time - ltp->tm_sec + dif_hour*3600L + dif_min*60L;
  2122. x+             /* use of tm_sec: get to beginning of minute. */
  2123. x+     if (!sched_ptr || tp->t_when < sched_ptr->t_when) {
  2124. x+         tp->t_next = sched_ptr;
  2125. x+         sched_ptr = tp;
  2126. x+     } else {
  2127. x+         tp1 = sched_ptr->t_next;
  2128. x+         tp2 = sched_ptr;
  2129. x+         while (tp1 && tp->t_when >= tp1->t_when) {
  2130. x+             tp2 = tp1;
  2131. x+             tp1 = tp1->t_next;
  2132. x+         }
  2133. x+         tp->t_next = tp1;
  2134. x+         tp2->t_next = tp;
  2135. x+     }
  2136. x+     tp->t_lex = saveblk(v);
  2137. x+ }
  2138. x+ 
  2139. x+ /*
  2140. x+  * Execute scheduled events
  2141. x+  */
  2142. x+ sched_run()
  2143. x+ {
  2144. x+     long    cur_time;
  2145. x+     register struct sched_event *tp, *tp1;
  2146. x+     struct wordent cmd, *nextword, *lastword;
  2147. x+     struct command *t = (struct command *) 0;
  2148. x+     char **v, *cp;
  2149. x+     extern int GettingInput;
  2150. x+ 
  2151. x+     sighold (SIGINT);
  2152. x+        
  2153. x+         if (GettingInput)
  2154. x+         Cookedmode();
  2155. x+ 
  2156. x+     time(&cur_time);
  2157. x+     tp = sched_ptr;
  2158. x+     while (tp && tp->t_when < cur_time) {
  2159. x+         err = NOSTR;
  2160. x+         cmd.word = "";
  2161. x+         lastword = &cmd;
  2162. x+         v = tp->t_lex;
  2163. x+         for (cp = *v; cp; cp = *++v) {
  2164. x+             nextword = (struct wordent *) calloc (1, sizeof cmd);
  2165. x+             nextword->word = savestr (cp);
  2166. x+             lastword->next = nextword;
  2167. x+             nextword->prev = lastword;
  2168. x+             lastword = nextword;
  2169. x+         }
  2170. x+         lastword->next = &cmd;
  2171. x+         cmd.prev = lastword;
  2172. x+         tp1 = tp;
  2173. x+         sched_ptr = tp = tp1->t_next;    /* looping termination cond: */
  2174. x+         blkfree (tp1->t_lex);        /* straighten out in case of */
  2175. x+         xfree ((char *) tp1);        /* command blow-up. */
  2176. x+ 
  2177. x+         /* expand aliases like process() does. */
  2178. x+         alias (&cmd);
  2179. x+         /* build a syntax tree for the command. */
  2180. x+         t = syntax (cmd.next, &cmd, 0);
  2181. x+         if (err)
  2182. x+             error (err);
  2183. x+         /* execute the parse tree. */
  2184. x+         execute (t, -1);
  2185. x+         /* done. free the lex list and parse tree. */
  2186. x+         freelex (&cmd), freesyn (t);
  2187. x+     }
  2188. x+         if (GettingInput) {    /* PWP */
  2189. x+         Rawmode();
  2190. x+         ClearLines();    /* do a real refresh since something may */
  2191. x+         ClearDisp();    /* have printed to the screen */
  2192. x+         Refresh();
  2193. x+     }
  2194. x+ 
  2195. x+     sigrelse (SIGINT);
  2196. x+ }
  2197. x+ /* kfk - end change */
  2198. \Rogue\Monster\
  2199. else
  2200.   echo "will not over write ./DIFFS.1"
  2201. fi
  2202. if [ `wc -c ./DIFFS.1 | awk '{printf $1}'` -ne 48696 ]
  2203. then
  2204. echo `wc -c ./DIFFS.1 | awk '{print "Got " $1 ", Expected " 48696}'`
  2205. fi
  2206. echo "Finished archive 6 of 6"
  2207. # if you want to concatenate archives, remove anything after this line
  2208. exit
  2209.  
  2210. -- 
  2211.  
  2212. Rich $alz
  2213. Cronus Project, BBN Labs            rsalz@bbn.com
  2214. Moderator, comp.sources.unix            sources@uunet.uu.net
  2215.