home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sources / misc / 4167 < prev    next >
Encoding:
Text File  |  1992-12-12  |  28.6 KB  |  1,152 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: sjg@zen.void.oz.au (Simon J. Gerraty)
  4. Subject:  v34i027:  pdksh - Public Domain Korn Shell, v4, Patch08
  5. Message-ID: <1992Dec13.033015.6978@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: d7d38bc976062eec9124f1095b7e38f3
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. Date: Sun, 13 Dec 1992 03:30:15 GMT
  11. Approved: kent@sparky.imd.sterling.com
  12. Lines: 1138
  13.  
  14. Submitted-by: sjg@zen.void.oz.au (Simon J. Gerraty)
  15. Posting-number: Volume 34, Issue 27
  16. Archive-name: pdksh/patch08
  17. Environment: UNIX
  18. Patch-To: pdksh: Volume 25, Issue 47-55
  19.  
  20. This is patch08.
  21.  
  22. It contains a couple of very useful bug fixes.
  23. Including that of pipes such as:
  24.  
  25. $ zcat foo.tar.Z | tar tvf - | more
  26.  
  27. not terminating immediately when you press 'q'.
  28.  
  29. Apply this patch by changing directory to the root
  30. of the source tree and using the command:
  31.  
  32.     patch -p0 < this_file
  33.  
  34. The following is a complete list of patches to date.
  35.  
  36. # PD ksh Version 4
  37. Prereq: 09-Nov-91
  38. Prereq: 10-Nov-91
  39. Prereq: 25-Nov-91
  40. Prereq: 25-Apr-92
  41. Prereq: 26-Apr-92
  42. Prereq: 27-Apr-92
  43. Prereq: 12-May-92
  44. Prereq: 02-Aug-92
  45. Prereq: 12-Aug-92
  46. *** PATCHDATES.old    Thu Aug 13 00:14:06 1992
  47. --- PATCHDATES    Sun Dec  6 00:14:24 1992
  48. ***************
  49. *** 8,10 ****
  50. --- 8,11 ----
  51.   12-May-92
  52.   02-Aug-92
  53.   12-Aug-92
  54. + 05-Dec-92
  55. *** README.old    Tue May 12 19:30:10 1992
  56. --- README    Sun Dec  6 00:14:30 1992
  57. ***************
  58. *** 1,5 ****
  59.           Public Domain Korn Shell
  60. !               Version 4.5
  61.   
  62.   PD KSH:
  63.   
  64. --- 1,5 ----
  65.           Public Domain Korn Shell
  66. !               Version 4.8
  67.   
  68.   PD KSH:
  69.   
  70. ***************
  71. *** 7,18 ****
  72.   intended to be the ultimate shell but rather a usable ksh work
  73.   alike.  For those of us who have to work on multiple systems it
  74.   is nice to have the same user interface on all.  I resisted
  75. ! moving to the ksh on a Bull system at work for nearly a year due
  76. ! to the lack of a ksh on my Sun systems.  When I first picked up
  77. ! the 3.2 PD KSH a couple of years ago, it took only a few minutes
  78. ! to convert a C-shell fan to a ksh fan :-)  Pdksh is not 100%
  79. ! compatible with the ksh.  Having said that, I use it daily
  80. ! beside a real ksh88 and find them virtually indistinguishable.
  81.   
  82.   I only run this shell on sun's and only for interactive use.  I
  83.   use it on sun4c, sun3 and sun386 systems.  The shell itself has
  84. --- 7,20 ----
  85.   intended to be the ultimate shell but rather a usable ksh work
  86.   alike.  For those of us who have to work on multiple systems it
  87.   is nice to have the same user interface on all.  I resisted
  88. ! moving to the ksh on a System V machine where I worked, for
  89. ! nearly a year due to the lack of a ksh on my Sun systems.  When
  90. ! I first picked up the 3.2 PD KSH a couple of years ago, it took
  91. ! only a few minutes to convert a C-shell fan to a ksh fan :-)
  92. ! Pdksh is not 100% compatible with the ksh.  Having said that, I
  93. ! use it daily beside a real ksh88 and find them virtually
  94. ! indistinguishable.  With one exception - arrays!  If some one
  95. ! feels like adding arrays, I for one would appreciate it :-)
  96.   
  97.   I only run this shell on sun's and only for interactive use.  I
  98.   use it on sun4c, sun3 and sun386 systems.  The shell itself has
  99. ***************
  100. *** 21,40 ****
  101.   MACHINES for details of systems that the shell has been built
  102.   on.
  103.   
  104. ! I have released this version of the shell (with the kind
  105. ! permission of the previous maintainers and major contributors) to
  106. ! ensure that it is available from usenet archive sites.  Of
  107. ! course it remains in the Public Domain.  Equally obviously
  108. ! neither myself nor any other contributors make any claims of
  109. ! suitability etc.  Ie. NO WARRANTY!!!  If you make any changes
  110. ! and distribute them, please leave your own finger prints in the
  111. ! source.  Its bad enough being flamed for my own bugs let alone
  112. ! anyone elses :-)
  113.   
  114. - WHATS NEW:
  115. - This update includes Job Control for System V (POSIX), many bug
  116. - fixes and a simple history file mechanism.  See sh/ChangeLog.
  117.   
  118.   HISTORY:
  119.   
  120. --- 23,37 ----
  121.   MACHINES for details of systems that the shell has been built
  122.   on.
  123.   
  124. ! I released version 4.0 of the shell (with the kind permission of
  125. ! the previous maintainers and major contributors) to ensure that
  126. ! it is available from usenet archive sites.  Of course it remains
  127. ! in the Public Domain.  Equally obviously neither myself nor any
  128. ! other contributors make any claims of suitability etc.  Ie. NO
  129. ! WARRANTY!!!  If you make any changes and distribute them, please
  130. ! leave your own finger prints in the source.  Its bad enough
  131. ! being flamed for my own bugs let alone anyone elses :-)
  132.   
  133.   
  134.   HISTORY:
  135.   
  136. *** bug-report.old    Thu Aug 13 00:14:09 1992
  137. --- bug-report    Sun Dec  6 00:14:34 1992
  138. ***************
  139. *** 2,8 ****
  140.   Subject: [area]: [synopsis]   [replace with actual area and short description]
  141.   
  142.   VERSION:
  143. !     PD KSH: 4.7 12-Aug-92
  144.       [Official patches will edit this line to indicate the patch level]
  145.   
  146.   MACHINE and OPERATING SYSTEM:
  147. --- 2,8 ----
  148.   Subject: [area]: [synopsis]   [replace with actual area and short description]
  149.   
  150.   VERSION:
  151. !     PD KSH: 4.8 05-Dec-92
  152.       [Official patches will edit this line to indicate the patch level]
  153.   
  154.   MACHINE and OPERATING SYSTEM:
  155. *** etc/ksh.kshrc.old    Mon Aug 10 22:00:08 1992
  156. --- etc/ksh.kshrc    Sun Dec  6 00:14:48 1992
  157. ***************
  158. *** 17,23 ****
  159.   #
  160.   
  161.   # RCSid:
  162. ! #    $Id: ksh.kshrc,v 1.3 1992/08/10 12:00:08 sjg Exp $
  163.   #
  164.   #    @(#)Copyright (c) 1991 Simon J. Gerraty
  165.   #
  166. --- 17,23 ----
  167.   #
  168.   
  169.   # RCSid:
  170. ! #    $Id: ksh.kshrc,v 1.4 1992/12/05 13:14:48 sjg Exp $
  171.   #
  172.   #    @(#)Copyright (c) 1991 Simon J. Gerraty
  173.   #
  174. ***************
  175. *** 97,102 ****
  176. --- 97,105 ----
  177.       alias cls=clear
  178.       alias logout=exit
  179.       alias bye=exit
  180. +     alias p='ps -l'
  181. +     alias j=jobs
  182. +     alias o='fg %-'
  183.   
  184.   
  185.   # add your favourite aliases here
  186. *** ksh.1.old    Mon Aug 10 21:59:15 1992
  187. --- ksh.1    Sun Dec  6 00:14:37 1992
  188. ***************
  189. *** 1,4 ****
  190. ! .\" $Id: ksh.1,v 1.2 1992/08/10 11:59:15 sjg Exp $
  191.   .nr OJ 1 \" Job Control
  192.   .nr OE 1 \" Command Editing
  193.   .nr OB 1 \" BSD enhanced ulimit options
  194. --- 1,4 ----
  195. ! .\" $Id: ksh.1,v 1.3 1992/12/05 13:14:37 sjg Exp $
  196.   .nr OJ 1 \" Job Control
  197.   .nr OE 1 \" Command Editing
  198.   .nr OB 1 \" BSD enhanced ulimit options
  199. ***************
  200. *** 88,94 ****
  201.   .SS Alternation
  202.   Csh provides a filename expansion method known as alternation.
  203.   This has been added into this version of ksh.
  204. ! When performing filename subsitution, you can get the shell to create
  205.   a set of strings for you. For example, `exampl{a,b,c,d,e}' will expand
  206.   to ``exampla examplb examplc exampld example''.
  207.   A comma separated set of strings in curly braces 
  208. --- 88,94 ----
  209.   .SS Alternation
  210.   Csh provides a filename expansion method known as alternation.
  211.   This has been added into this version of ksh.
  212. ! When performing filename substitution, you can get the shell to create
  213.   a set of strings for you. For example, `exampl{a,b,c,d,e}' will expand
  214.   to ``exampla examplb examplc exampld example''.
  215.   A comma separated set of strings in curly braces 
  216. ***************
  217. *** 112,118 ****
  218.   .IP FCEDIT
  219.   The editor used by the \fIfc\fP command.
  220.   During startup the shell checks the value of \fBFCEDIT\fP, 
  221. ! \fBEDITOR\fP and finally \fBVISUAL\fP to try and determin what
  222.   command line edit mode to use.  Note that this is not strictly
  223.   ksh compatible behaviour.
  224.   .IP COLUMNS
  225. --- 112,118 ----
  226.   .IP FCEDIT
  227.   The editor used by the \fIfc\fP command.
  228.   During startup the shell checks the value of \fBFCEDIT\fP, 
  229. ! \fBEDITOR\fP and finally \fBVISUAL\fP to try and determine what
  230.   command line edit mode to use.  Note that this is not strictly
  231.   ksh compatible behaviour.
  232.   .IP COLUMNS
  233. ***************
  234. *** 178,184 ****
  235.   A single \fB#\fP results in the shortest match,
  236.   two \fB#\fP's results in the longest match.
  237.   .IP "${var%pattern} ${var%%pattern}"
  238. ! Like \fB#\fP substition, but deleting from the end of the value.
  239.   .SS Expressions
  240.   Expressions can be used with the \fBlet\fP command,
  241.   as numeric arguments to the \fBtest\fP command,
  242. --- 178,184 ----
  243.   A single \fB#\fP results in the shortest match,
  244.   two \fB#\fP's results in the longest match.
  245.   .IP "${var%pattern} ${var%%pattern}"
  246. ! Like \fB#\fP substitution, but deleting from the end of the value.
  247.   .SS Expressions
  248.   Expressions can be used with the \fBlet\fP command,
  249.   as numeric arguments to the \fBtest\fP command,
  250. ***************
  251. *** 250,256 ****
  252.   .IP "fc [\fB\-e\fP \fIeditor\fP] [\fB\-lnr\fP] [\fIfirst\fP [\fIlast\fP]]"
  253.   \fIFirst\fP and \fIlast\fP select commands.
  254.   Commands can be selected by history number,
  255. ! or a string specifing the most recent command starting with that string.
  256.   The \fB\-l\fP option lists the command on stdout,
  257.   and \fB\-n\fP inhibits the default command numbers.
  258.   The \fB\-r\fP option reverses the order of the list.
  259. --- 250,256 ----
  260.   .IP "fc [\fB\-e\fP \fIeditor\fP] [\fB\-lnr\fP] [\fIfirst\fP [\fIlast\fP]]"
  261.   \fIFirst\fP and \fIlast\fP select commands.
  262.   Commands can be selected by history number,
  263. ! or a string specifying the most recent command starting with that string.
  264.   The \fB\-l\fP option lists the command on stdout,
  265.   and \fB\-n\fP inhibits the default command numbers.
  266.   The \fB\-r\fP option reverses the order of the list.
  267. ***************
  268. *** 340,346 ****
  269.   .ta 5n 10n
  270.   \t\-i\tThe variable's value is stored as an integer.
  271.   .br
  272. ! \t\-x\tThe variable is exported to the enviroment.
  273.   .br
  274.   \t\-r\tThe variable is read-only cannot be reassigned a value.
  275.   .br
  276. --- 340,346 ----
  277.   .ta 5n 10n
  278.   \t\-i\tThe variable's value is stored as an integer.
  279.   .br
  280. ! \t\-x\tThe variable is exported to the environment.
  281.   .br
  282.   \t\-r\tThe variable is read-only cannot be reassigned a value.
  283.   .br
  284. ***************
  285. *** 466,472 ****
  286.   job reporting.  The jobs and kill commands
  287.   functions as above, and you will
  288.   be informed when background jobs complete.  Fg and bg are not 
  289. ! availiable.
  290.   .PD
  291.   .br
  292.   .SS "Interactive Input Line Editing"
  293. --- 466,472 ----
  294.   job reporting.  The jobs and kill commands
  295.   functions as above, and you will
  296.   be informed when background jobs complete.  Fg and bg are not 
  297. ! available.
  298.   .PD
  299.   .br
  300.   .SS "Interactive Input Line Editing"
  301. ***************
  302. *** 540,546 ****
  303.   (note that the ASCII
  304.   .SM ESC
  305.   character is written as \s-1^[\s0\|),
  306. ! then the editing function performed is decribed.
  307.   Note that
  308.   .I "editing command"
  309.   names are used only with the
  310. --- 540,546 ----
  311.   (note that the ASCII
  312.   .SM ESC
  313.   character is written as \s-1^[\s0\|),
  314. ! then the editing function performed is described.
  315.   Note that
  316.   .I "editing command"
  317.   names are used only with the
  318. ***************
  319. *** 873,879 ****
  320.   .br
  321.   \fB[\fP \fIexpression\fP \fB]\fP
  322.   .SH DESCRIPTION
  323. ! \fBTest\f evalutates the \fIexpression\fP and returns zero status if true,
  324.   and non-zero status otherwise.
  325.   It is normally used as the controlling command of the \fBif\fP and \fBwhile\fP statements.
  326.   .LP
  327. --- 873,879 ----
  328.   .br
  329.   \fB[\fP \fIexpression\fP \fB]\fP
  330.   .SH DESCRIPTION
  331. ! \fBTest\f evaluates the \fIexpression\fP and returns zero status if true,
  332.   and non-zero status otherwise.
  333.   It is normally used as the controlling command of the \fBif\fP and \fBwhile\fP statements.
  334.   .LP
  335. *** sh/ChangeLog.old    Thu Aug 13 00:15:18 1992
  336. --- sh/ChangeLog    Sun Dec  6 00:15:01 1992
  337. ***************
  338. *** 1,3 ****
  339. --- 1,40 ----
  340. + Sat Dec  5 23:54:40 1992  Simon J. Gerraty  (sjg@zen)
  341. +     * finally fixed the fd leakage that caused pipes to not terminate
  342. +     immediately.
  343. + Sat Nov 28 23:01:38 1992  Simon J. Gerraty  (sjg@zen)
  344. +     * Makefile: added install target
  345. + Wed Nov 25 09:10:11 1992  Simon J. Gerraty  (sjg@zen)
  346. +     * c_cd(c_ksh.c): fixed bug causing cd ., cd .. to look at $CDPATH.
  347. + Thu Nov 19 23:32:42 1992  Simon J. Gerraty  (sjg@zen)
  348. +     * For now bind emacs mode complete-list to ESC=
  349. + Tue Sep 15 15:24:38 1992  Simon J. Gerraty  (sjg@zen)
  350. +     * main.c: call init_editmode() between processing .profile and
  351. +     .kshrc so that edit mode can be explicitly set in .kshrc
  352. +     regardless of FCEDIT, EDITOR and VISUAL values.
  353. + Tue Sep 15 15:08:06 1992  Philippe Michel (michel@thomson-lcr.fr) 
  354. +     * main.c: fixed bug in command line argument processing.
  355. + Fri Aug 21 15:24:37 1992  Bruce Momjian  (root%candle.uucp@bts.com)
  356. +     * exec.c: replace all calls of execute(tree, 0) with 
  357. +     execute(tree, flags & XXWHL) to ensure it is passed to children. 
  358. + Thu Aug 20 23:18:45 1992  Simon J. Gerraty  (sjg@zen)
  359. +     * fixed bug in complex_history: histsize not initialized before
  360. +     call to alloc().
  361.   Thu Aug 13 00:00:42 1992  Simon J. Gerraty  (sjg@zen)
  362.   
  363.       * setstr(), varsub(): be robust when given dud args.
  364. *** sh/Makefile.old    Thu Aug 13 00:00:07 1992
  365. --- sh/Makefile    Sun Dec  6 00:15:06 1992
  366. ***************
  367. *** 1,5 ****
  368.   # PD Bourne/Korn Shell
  369. ! # $Id: Makefile,v 1.3 1992/08/10 12:02:18 sjg Exp $
  370.   
  371.   SHELL = /bin/sh
  372.   MAKE  = make
  373. --- 1,5 ----
  374.   # PD Bourne/Korn Shell
  375. ! # $Id: Makefile,v 1.4 1992/12/05 13:15:06 sjg Exp $
  376.   
  377.   SHELL = /bin/sh
  378.   MAKE  = make
  379. ***************
  380. *** 6,11 ****
  381. --- 6,17 ----
  382.   
  383.   LN    = ln -s
  384.   
  385. + CHMOD=chmod
  386. + prefix=/usr/local
  387. + target=$(prefix)/bin/ksh
  388.   # You _can_ build this shell without the ../std tree if your
  389.   # system provides a sufficiently POSIX environment, or if your
  390.   # BSD system is a Sun or close.  If not try ../std.
  391. ***************
  392. *** 107,116 ****
  393.       makedepend $(CFLAGS) $(SRCS1) $(SRCS2)
  394.   
  395.   install:
  396. !     @echo "Try:"
  397. !     @echo "cp ksh /bin"
  398. !     @echo "strip /bin/ksh"
  399. !     @echo "chmod 555 /bin/ksh"
  400.   
  401.   .c.s:
  402.       $(CC) $(CFLAGS) -S -o $@ $<
  403. --- 113,121 ----
  404.       makedepend $(CFLAGS) $(SRCS1) $(SRCS2)
  405.   
  406.   install:
  407. !     -if test -f $(target); then mv $(target) $(target).old; fi
  408. !     cp ksh $(target)
  409. !     $(CHMOD) 755 $(target)
  410.   
  411.   .c.s:
  412.       $(CC) $(CFLAGS) -S -o $@ $<
  413. *** sh/c_ksh.c.old    Sat Apr 25 18:33:28 1992
  414. --- sh/c_ksh.c    Sun Dec  6 00:15:11 1992
  415. ***************
  416. *** 3,9 ****
  417.    */
  418.   
  419.   #ifndef lint
  420. ! static char *RCSid = "$Id: c_ksh.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  421.   #endif
  422.   
  423.   #include "stdh.h"
  424. --- 3,9 ----
  425.    */
  426.   
  427.   #ifndef lint
  428. ! static char *RCSid = "$Id: c_ksh.c,v 1.3 1992/12/05 13:15:11 sjg Exp $";
  429.   #endif
  430.   
  431.   #include "stdh.h"
  432. ***************
  433. *** 78,85 ****
  434.           dir = strval(v_oldpwd = global("OLDPWD"));
  435.           prt = 1;
  436.       }
  437. !     if (dir[0] == '/' || (dir[0] == '.' && (dir[1] == '/' ||
  438. !         (dir[1] == '.' && dir[2] == '/')))) {
  439.           /*
  440.            * dir is an explicitly named path, so no CDPATH search
  441.            */
  442. --- 78,87 ----
  443.           dir = strval(v_oldpwd = global("OLDPWD"));
  444.           prt = 1;
  445.       }
  446. !     if (dir[0] == '/' ||
  447. !         (dir[0] == '.' &&
  448. !          (dir[1] == '.' || dir[1] == '/' || dir[1] == '\0'))) {
  449.           /*
  450.            * dir is an explicitly named path, so no CDPATH search
  451.            */
  452. *** sh/config.h.old    Thu Aug 13 00:15:22 1992
  453. --- sh/config.h    Sun Dec  6 00:15:15 1992
  454. ***************
  455. *** 1,7 ****
  456.   /*
  457.    * Configuration file for the PD ksh
  458.    *
  459. !  * RCSid: $Id: config.h,v 1.5 1992/08/12 14:15:22 sjg Exp $
  460.    */
  461.   
  462.   #ifndef    _CONFIG_H
  463. --- 1,7 ----
  464.   /*
  465.    * Configuration file for the PD ksh
  466.    *
  467. !  * RCSid: $Id: config.h,v 1.6 1992/12/05 13:15:15 sjg Exp $
  468.    */
  469.   
  470.   #ifndef    _CONFIG_H
  471. ***************
  472. *** 49,61 ****
  473.   /* #define    SILLY            /* Game of life in EMACS mode */
  474.   /* #define    SWTCH            /* Handle SWTCH for shl(1) */
  475.   
  476. ! /*
  477. !  * better to leave this one out, and let users that
  478. !  * like it add
  479. !  *   bind '^[^['=complete-list
  480. !  * to their .kshrc
  481. !  */
  482. ! /*#define COMPLETE_LIST            /* default to Emacs style completion */
  483.   /*
  484.    * ALTERNATIONS is csh not ksh, but it is such a nice feature...
  485.    */
  486. --- 49,55 ----
  487.   /* #define    SILLY            /* Game of life in EMACS mode */
  488.   /* #define    SWTCH            /* Handle SWTCH for shl(1) */
  489.   
  490.   /*
  491.    * ALTERNATIONS is csh not ksh, but it is such a nice feature...
  492.    */
  493. *** sh/emacs.c.old    Mon Aug 10 22:02:31 1992
  494. --- sh/emacs.c    Sun Dec  6 00:15:20 1992
  495. ***************
  496. *** 10,16 ****
  497.   #ifdef EMACS
  498.   
  499.   #ifndef lint
  500. ! static char *RCSid = "$Id: emacs.c,v 1.3 1992/08/10 12:02:31 sjg Exp $";
  501.   #endif
  502.   
  503.   #include "stdh.h"
  504. --- 10,16 ----
  505.   #ifdef EMACS
  506.   
  507.   #ifndef lint
  508. ! static char *RCSid = "$Id: emacs.c,v 1.4 1992/12/05 13:15:20 sjg Exp $";
  509.   #endif
  510.   
  511.   #include "stdh.h"
  512. ***************
  513. *** 203,215 ****
  514.       {x_stuff,     "stuff",        0,     0,    0 },
  515.       {x_transpose,    "transpose-chars",    0, CTRL('T'),    0 },
  516.   #endif
  517. - #ifdef COMPLETE_LIST
  518. -     {x_complete,    "complete",        1,     0,    0 },
  519. -      {x_comp_list,    "complete-list",    1, CTRL('['),    0 },
  520. - #else
  521.       {x_complete,    "complete",        1, CTRL('['),    0 },
  522. !      {x_comp_list,    "complete-list",    1,      0,    0 },
  523. ! #endif
  524.       {x_enumerate,    "list",            1,    '?',    0 },
  525.       {x_comp_file,    "complete-file",    1, CTRL('X'),    0 },
  526.       {x_comp_comm,    "complete-command",    2, CTRL('['),    0 },
  527. --- 203,210 ----
  528.       {x_stuff,     "stuff",        0,     0,    0 },
  529.       {x_transpose,    "transpose-chars",    0, CTRL('T'),    0 },
  530.   #endif
  531.       {x_complete,    "complete",        1, CTRL('['),    0 },
  532. !         {x_comp_list,    "complete-list",    1,    '=',    0 },
  533.       {x_enumerate,    "list",            1,    '?',    0 },
  534.       {x_comp_file,    "complete-file",    1, CTRL('X'),    0 },
  535.       {x_comp_comm,    "complete-command",    2, CTRL('['),    0 },
  536. *** sh/eval.c.old    Thu Aug 13 00:15:28 1992
  537. --- sh/eval.c    Sun Dec  6 00:15:25 1992
  538. ***************
  539. *** 3,9 ****
  540.    */
  541.   
  542.   #ifndef lint
  543. ! static char *RCSid = "$Id: eval.c,v 1.4 1992/08/12 14:15:28 sjg Exp $";
  544.   #endif
  545.   
  546.   #include "stdh.h"
  547. --- 3,9 ----
  548.    */
  549.   
  550.   #ifndef lint
  551. ! static char *RCSid = "$Id: eval.c,v 1.5 1992/12/05 13:15:25 sjg Exp $";
  552.   #endif
  553.   
  554.   #include "stdh.h"
  555. ***************
  556. *** 469,479 ****
  557.           ofd1 = savefd(1);
  558.           dup2(pv[1], 1);
  559.           close(pv[1]);
  560. ! #if 0
  561. !         exchild(t, XXCOM|XPIPEO);
  562. ! #else
  563.           execute(t, XFORK|XXCOM|XPIPEO);
  564. - #endif
  565.           dup2(ofd1, 1);
  566.           close(ofd1);
  567.           xp->split = 1;    /* waitlast() */
  568. --- 469,477 ----
  569.           ofd1 = savefd(1);
  570.           dup2(pv[1], 1);
  571.           close(pv[1]);
  572. !         (void) fd_clexec(pv[0]);
  573. !         (void) fd_clexec(ofd1);
  574.           execute(t, XFORK|XXCOM|XPIPEO);
  575.           dup2(ofd1, 1);
  576.           close(ofd1);
  577.           xp->split = 1;    /* waitlast() */
  578. *** sh/exec.c.old    Mon Aug 10 22:02:38 1992
  579. --- sh/exec.c    Sun Dec  6 00:15:29 1992
  580. ***************
  581. *** 3,9 ****
  582.    */
  583.   
  584.   #ifndef lint
  585. ! static char *RCSid = "$Id: exec.c,v 1.4 1992/08/10 12:02:38 sjg Exp $";
  586.   #endif
  587.   
  588.   #include "stdh.h"
  589. --- 3,9 ----
  590.    */
  591.   
  592.   #ifndef lint
  593. ! static char *RCSid = "$Id: exec.c,v 1.5 1992/12/05 13:15:29 sjg Exp $";
  594.   #endif
  595.   
  596.   #include "stdh.h"
  597. ***************
  598. *** 46,56 ****
  599. --- 46,66 ----
  600.   {
  601.     (void) memset(clexec_tab, 0, sizeof(clexec_tab)-1);
  602.   }
  603. + #endif
  604.   
  605. + /*
  606. +  * we now use this function always.
  607. +  */
  608.   int
  609.   fd_clexec(fd)
  610.     int fd;
  611.   {
  612. + #ifndef F_SETFD
  613. +   static int once = 0;
  614. +   if (once++ == 0)
  615. +     init_clexec();
  616.     if (fd < sizeof(clexec_tab))
  617.     {
  618.       clexec_tab[fd] = 1;
  619. ***************
  620. *** 57,64 ****
  621.       return 0;
  622.     }
  623.     return -1;
  624. ! }
  625.   #endif
  626.   
  627.   
  628.   /*
  629. --- 67,76 ----
  630.       return 0;
  631.     }
  632.     return -1;
  633. ! #else
  634. !   return fcntl(fd, F_SETFD, 1);
  635.   #endif
  636. + }
  637.   
  638.   
  639.   /*
  640. ***************
  641. *** 123,128 ****
  642. --- 135,142 ----
  643.           while (t->type == TPIPE) {
  644.               openpipe(pv);
  645.               (void) dup2(pv[1], 1);    /* stdout of curr */
  646. +             (void) fd_clexec(pv[0]);
  647. +             (void) fd_clexec(pv[1]);
  648.               exchild(t->left, flags);
  649.               (void) dup2(pv[0], 0);    /* stdin of next */
  650.               closepipe(pv);
  651. ***************
  652. *** 131,136 ****
  653. --- 145,152 ----
  654.           }
  655.           flags &= ~ XPIPEO;
  656.           (void) dup2(e.savefd[1], 1); /* stdout of last */
  657. +         (void) fd_clexec(e.savefd[0]);
  658. +         (void) fd_clexec(e.savefd[1]);
  659.           exchild(t, flags);
  660.           (void) dup2(e.savefd[0], 0); /* close pipe in */
  661.           if (!(flags&XBGND))
  662. ***************
  663. *** 139,148 ****
  664.   
  665.         case TLIST:
  666.           while (t->type == TLIST) {
  667. !             execute(t->left, 0);
  668.               t = t->right;
  669.           }
  670. !         rv = execute(t, 0);
  671.           break;
  672.   
  673.         case TASYNC:
  674. --- 155,164 ----
  675.   
  676.         case TLIST:
  677.           while (t->type == TLIST) {
  678. !             execute(t->left, flags & XXWHL);
  679.               t = t->right;
  680.           }
  681. !         rv = execute(t, flags & XXWHL);
  682.           break;
  683.   
  684.         case TASYNC:
  685. ***************
  686. *** 151,159 ****
  687.   
  688.         case TOR:
  689.         case TAND:
  690. !         rv = execute(t->left, 0);
  691.           if (t->right != NULL && (rv == 0) == (t->type == TAND))
  692. !             rv = execute(t->right, 0);
  693.           break;
  694.   
  695.         case TFOR:
  696. --- 167,175 ----
  697.   
  698.         case TOR:
  699.         case TAND:
  700. !         rv = execute(t->left, flags & XXWHL);
  701.           if (t->right != NULL && (rv == 0) == (t->type == TAND))
  702. !             rv = execute(t->right, flags & XXWHL);
  703.           break;
  704.   
  705.         case TFOR:
  706. ***************
  707. *** 165,171 ****
  708.                   goto Break1;
  709.           while (*ap != NULL) {
  710.               setstr(global(t->str), *ap++);
  711. !             rv = execute(t->left, 0);
  712.           }
  713.         Break1:
  714.           break;
  715. --- 181,187 ----
  716.                   goto Break1;
  717.           while (*ap != NULL) {
  718.               setstr(global(t->str), *ap++);
  719. !             rv = execute(t->left, flags & XXWHL);
  720.           }
  721.         Break1:
  722.           break;
  723. ***************
  724. *** 183,189 ****
  725.               if ((cp = do_selectargs(ap, cp)) == (char *)1)
  726.                   break;
  727.               setstr(global(t->str), cp);
  728. !             rv = execute(t->left, 0);
  729.           }
  730.           break;
  731.           
  732. --- 199,205 ----
  733.               if ((cp = do_selectargs(ap, cp)) == (char *)1)
  734.                   break;
  735.               setstr(global(t->str), cp);
  736. !             rv = execute(t->left, flags & XXWHL);
  737.           }
  738.           break;
  739.           
  740. ***************
  741. *** 193,199 ****
  742.           while ((i = setjmp(e.jbuf)))
  743.               if (i == LBREAK)
  744.                   goto Break2;
  745. !         while ((execute(t->left, 0) == 0) == (t->type == TWHILE))
  746.               rv = execute(t->right, XXWHL);
  747.         Break2:
  748.           break;
  749. --- 209,215 ----
  750.           while ((i = setjmp(e.jbuf)))
  751.               if (i == LBREAK)
  752.                   goto Break2;
  753. !         while ((execute(t->left, flags & XXWHL) == 0) == (t->type == TWHILE))
  754.               rv = execute(t->right, XXWHL);
  755.         Break2:
  756.           break;
  757. ***************
  758. *** 202,210 ****
  759.         case TELIF:
  760.           if (t->right == NULL)
  761.               break;    /* should be error */
  762. !         rv = execute(t->left, 0) == 0 ?
  763. !             execute(t->right->left, 0) :
  764. !             execute(t->right->right, 0);
  765.           break;
  766.   
  767.         case TCASE:
  768. --- 218,226 ----
  769.         case TELIF:
  770.           if (t->right == NULL)
  771.               break;    /* should be error */
  772. !         rv = execute(t->left, flags & XXWHL) == 0 ?
  773. !             execute(t->right->left, flags & XXWHL) :
  774. !             execute(t->right->right, flags & XXWHL);
  775.           break;
  776.   
  777.         case TCASE:
  778. ***************
  779. *** 215,225 ****
  780.                   goto Found;
  781.           break;
  782.         Found:
  783. !         rv = execute(t->left, 0);
  784.           break;
  785.   
  786.         case TBRACE:
  787. !         rv = execute(t->left, 0);
  788.           break;
  789.   
  790.         case TFUNCT:
  791. --- 231,241 ----
  792.                   goto Found;
  793.           break;
  794.         Found:
  795. !         rv = execute(t->left, flags & XXWHL);
  796.           break;
  797.   
  798.         case TBRACE:
  799. !         rv = execute(t->left, flags & XXWHL);
  800.           break;
  801.   
  802.         case TFUNCT:
  803. ***************
  804. *** 351,357 ****
  805.           if (setjmp(e.jbuf))
  806.               rv = exstat; /* return # */
  807.           else
  808. !             rv = execute(tp->val.t, 0);
  809.           break;
  810.   
  811.       case CEXEC:        /* executable command */
  812. --- 367,373 ----
  813.           if (setjmp(e.jbuf))
  814.               rv = exstat; /* return # */
  815.           else
  816. !             rv = execute(tp->val.t, flags & XXWHL);
  817.           break;
  818.   
  819.       case CEXEC:        /* executable command */
  820. *** sh/history.c.old    Thu Aug 13 00:15:33 1992
  821. --- sh/history.c    Sun Dec  6 00:15:34 1992
  822. ***************
  823. *** 5,11 ****
  824.    */
  825.   
  826.   #ifndef lint
  827. ! static char *RCSid = "$Id: history.c,v 1.4 1992/08/12 14:15:33 sjg Exp $";
  828.   #endif
  829.   /*
  830.    *    This file contains
  831. --- 5,11 ----
  832.    */
  833.   
  834.   #ifndef lint
  835. ! static char *RCSid = "$Id: history.c,v 1.5 1992/12/05 13:15:34 sjg Exp $";
  836.   #endif
  837.   /*
  838.    *    This file contains
  839. ***************
  840. *** 643,650 ****
  841.   
  842.       histfd = fcntl(histfd, F_DUPFD, FDBASE);
  843.       
  844. !     (void) fcntl(histfd, F_SETFD, 1); /* close on exec */
  845. !     
  846.       (void) flock(histfd, LOCK_EX);
  847.   
  848.       hsize = lseek(histfd, 0L, L_XTND);
  849. --- 643,650 ----
  850.   
  851.       histfd = fcntl(histfd, F_DUPFD, FDBASE);
  852.       
  853. !     (void) fd_clexec(histfd);
  854.       (void) flock(histfd, LOCK_EX);
  855.   
  856.       hsize = lseek(histfd, 0L, L_XTND);
  857. *** sh/io.c.old    Mon Aug 10 22:02:49 1992
  858. --- sh/io.c    Sun Dec  6 00:15:39 1992
  859. ***************
  860. *** 3,9 ****
  861.    */
  862.   
  863.   #ifndef lint
  864. ! static char *RCSid = "$Id: io.c,v 1.3 1992/08/10 12:02:49 sjg Exp $";
  865.   #endif
  866.   
  867.   #include "stdh.h"
  868. --- 3,9 ----
  869.    */
  870.   
  871.   #ifndef lint
  872. ! static char *RCSid = "$Id: io.c,v 1.4 1992/12/05 13:15:39 sjg Exp $";
  873.   #endif
  874.   
  875.   #include "stdh.h"
  876. ***************
  877. *** 147,157 ****
  878.                   return -1;
  879.               else
  880.                   errorf("too many files open in shell\n");
  881. - #ifdef F_SETFD
  882. -         (void) fcntl(nfd, F_SETFD, 1);
  883. - #else
  884.           (void) fd_clexec(ttyfd);
  885. - #endif
  886.           close(fd);
  887.       } else
  888.           nfd = fd;
  889. --- 147,153 ----
  890. *** sh/jobs.c.old    Mon Aug 10 22:02:52 1992
  891. --- sh/jobs.c    Sun Dec  6 00:15:43 1992
  892. ***************
  893. *** 2,8 ****
  894.    * Process and job control
  895.    */
  896.   #ifndef lint
  897. ! static char *RCSid = "$Id: jobs.c,v 1.5 1992/08/10 12:02:52 sjg Exp $";
  898.   #endif
  899.   
  900.   /*
  901. --- 2,8 ----
  902.    * Process and job control
  903.    */
  904.   #ifndef lint
  905. ! static char *RCSid = "$Id: jobs.c,v 1.6 1992/12/05 13:15:43 sjg Exp $";
  906.   #endif
  907.   
  908.   /*
  909. ***************
  910. *** 320,327 ****
  911.       for (i = (flags&XXWHL) ? 1 : 0; i < NUFILE; i++)
  912.           flushshf(i);
  913.   
  914. -     /* create child process */
  915. -     forksleep = 0;
  916.   #ifdef JOBS
  917.       /* don't allow SIGCHLD until we are ready */
  918.   
  919. --- 320,325 ----
  920. ***************
  921. *** 331,336 ****
  922. --- 329,336 ----
  923.       sigsetmask(sm_sigchld);
  924.   # endif
  925.   #endif
  926. +     /* create child process */
  927. +     forksleep = 0;
  928.       while ((i = fork()) < 0 && errno == EAGAIN && forksleep < 32) {
  929.           if (forksleep) {
  930.               sleep(forksleep);
  931. *** sh/main.c.old    Thu Aug 13 00:15:39 1992
  932. --- sh/main.c    Sun Dec  6 00:15:49 1992
  933. ***************
  934. *** 3,9 ****
  935.    */
  936.   
  937.   #ifndef lint
  938. ! static char *RCSid = "$Id: main.c,v 1.6 1992/08/12 14:15:39 sjg Exp $";
  939.   #endif
  940.   
  941.   #define    EXTERN                /* define EXTERNs in sh.h */
  942. --- 3,9 ----
  943.    */
  944.   
  945.   #ifndef lint
  946. ! static char *RCSid = "$Id: main.c,v 1.7 1992/12/05 13:15:49 sjg Exp $";
  947.   #endif
  948.   
  949.   #define    EXTERN                /* define EXTERNs in sh.h */
  950. ***************
  951. *** 119,127 ****
  952.   #endif
  953.       ainit(&aperm);        /* initialize permanent Area */
  954.   
  955. - #ifndef F_SETFD
  956. -   init_clexec();
  957. - #endif
  958.       /* set up base enviroment */
  959.       e.type = E_NONE;
  960.       ainit(&e.area);
  961. --- 119,124 ----
  962. ***************
  963. *** 238,248 ****
  964.       }
  965.       if (s->type == STTY) {
  966.           ttyfd = fcntl(0, F_DUPFD, FDBASE);
  967. - #ifdef F_SETFD
  968. -         (void) fcntl(ttyfd, F_SETFD, 1);
  969. - #else
  970.           (void) fd_clexec(ttyfd);
  971. - #endif
  972.   #ifdef EMACS
  973.             x_init_emacs();
  974.   #endif
  975. --- 235,241 ----
  976. ***************
  977. *** 254,269 ****
  978.       if (!qflag)
  979.           ignoresig(SIGQUIT);
  980.   
  981. !     l->argv = &argv[argi];
  982.       l->argc = argc - argi;
  983.       l->argv[0] = name;
  984.       resetopts();
  985.   
  986. !     if (name[0] == '-') {
  987.           flag[FTALKING] = 1;
  988.           (void) include("/etc/profile");
  989.           (void) include(".profile");
  990.       }
  991.   
  992.       /* include $ENV */
  993.       arg = substitute(strval(global("ENV")), DOTILDE);
  994. --- 247,271 ----
  995.       if (!qflag)
  996.           ignoresig(SIGQUIT);
  997.   
  998. !     l->argv = &argv[argi - 1];
  999.       l->argc = argc - argi;
  1000.       l->argv[0] = name;
  1001.       resetopts();
  1002.   
  1003. !     if (name[0] == '-' ||
  1004. !         ((arg = strrchr(name, '/')) && *++arg == '-')) {
  1005.           flag[FTALKING] = 1;
  1006.           (void) include("/etc/profile");
  1007.           (void) include(".profile");
  1008.       }
  1009. +     /*
  1010. +      * do this after reading *profile but before
  1011. +      * reading $ENV if any.
  1012. +      */
  1013. + #if defined(EMACS) || defined(VI)
  1014. +     if (flag[FTALKING])
  1015. +       init_editmode();
  1016. + #endif
  1017.   
  1018.       /* include $ENV */
  1019.       arg = substitute(strval(global("ENV")), DOTILDE);
  1020. ***************
  1021. *** 278,286 ****
  1022.         signal(SIGTERM, trapsig);
  1023.   #endif
  1024.         ignoresig(SIGINT);
  1025. - #if defined(EMACS) || defined(VI)
  1026. -       init_editmode();
  1027. - #endif
  1028.       } else
  1029.         flag[FHASHALL] = 1;
  1030.   
  1031. --- 280,285 ----
  1032. *** sh/patchlevel.h.old    Thu Aug 13 00:15:45 1992
  1033. --- sh/patchlevel.h    Sun Dec  6 00:15:52 1992
  1034. ***************
  1035. *** 1,6 ****
  1036.   /*
  1037.    * PD KSH
  1038. !  * $Id: patchlevel.h,v 4.7 1992/08/12 14:15:45 sjg Exp $
  1039.    */
  1040.   #define VERSION        4
  1041. ! #define PATCHLEVEL    7
  1042. --- 1,6 ----
  1043.   /*
  1044.    * PD KSH
  1045. !  * $Id: patchlevel.h,v 4.8 1992/12/05 13:15:52 sjg Exp $
  1046.    */
  1047.   #define VERSION        4
  1048. ! #define PATCHLEVEL    8
  1049. *** sh/version.c.old    Thu Aug 13 00:15:53 1992
  1050. --- sh/version.c    Sun Dec  6 00:15:55 1992
  1051. ***************
  1052. *** 3,9 ****
  1053.    */
  1054.   
  1055.   #ifndef lint
  1056. ! static char *RCSid = "$Id: version.c,v 1.6 1992/08/12 14:15:53 sjg Exp $";
  1057.   #endif
  1058.   
  1059.   #include "stdh.h"
  1060. --- 3,9 ----
  1061.    */
  1062.   
  1063.   #ifndef lint
  1064. ! static char *RCSid = "$Id: version.c,v 1.7 1992/12/05 13:15:55 sjg Exp $";
  1065.   #endif
  1066.   
  1067.   #include "stdh.h"
  1068. ***************
  1069. *** 12,59 ****
  1070.   #include "patchlevel.h"
  1071.   
  1072.   char ksh_version [] =
  1073. !     "KSH_VERSION=@(#)PD KSH v4.7 92/08/12";
  1074.   
  1075. - /***
  1076. - $Log: version.c,v $
  1077. -  * Revision 1.6  1992/08/12  14:15:53  sjg
  1078. -  * Patch07: fix some build problems,
  1079. -  * and avoid core dump from arg processing bug.
  1080. -  *
  1081. -  * Revision 1.5  1992/08/10  12:03:29  sjg
  1082. -  * Update for patch06.
  1083. -  * Contributions from Peter Collinson, Neil Smithline and sjg
  1084. -  *
  1085. -  * Revision 1.4  1992/05/12  09:30:37  sjg
  1086. -  * see ChangeLog
  1087. -  *
  1088. -  * Revision 1.3  1992/05/03  08:29:20  sjg
  1089. -  * Update for Patch05
  1090. -  *
  1091. -  * Revision 1.2  1992/04/25  08:33:28  sjg
  1092. -  * Added RCS key.
  1093. -  *
  1094. -  * Revision 1.1  1992/04/18  05:51:48  sjg
  1095. -  * Initial revision
  1096. -  *
  1097. - Version  4.0  91/11/09  sjg
  1098. - distribution
  1099. - Revision 3.3  89/03/27  15:52:29  egisin
  1100. - distribution
  1101. - Revision 3.2  88/12/14  20:10:41  egisin
  1102. - many fixes
  1103. - Revision 3.1  88/11/03  09:18:36  egisin
  1104. - alpha distribution
  1105. - Revision 1.3  88/10/20  17:34:03  egisin
  1106. - added @(#) to ksh_version
  1107. - Revision 1.2  88/09/27  19:01:58  egisin
  1108. - fix version.c
  1109. - Revision 1.1  88/09/27  18:59:06  egisin
  1110. - Initial revision
  1111. - ***/
  1112.   
  1113. --- 12,17 ----
  1114.   #include "patchlevel.h"
  1115.   
  1116.   char ksh_version [] =
  1117. !     "KSH_VERSION=@(#)PD KSH v4.8 92/12/05";
  1118.   
  1119.   
  1120.  
  1121. exit 0 # Just in case...
  1122.