apply some fixes from OpenBSD and don't apply some others
but sync RCS IDs for easier future adaption: * Simplify savefd() by removing the "noclose" flag and make noclose behavior the default. Almost all uses of savefd() are followed by an implicit or explicit close. * fix typos * might as well make ksh_getopt() match real getopt(), ie. get rid of that stupid EOF concept that was never true. adobriyan@gmail * use SEEK_* for lseek() * fix lint comments, no functional changes * remove excessive optimization; from adobriyan@gmail * only santa checks things twice; from adobriyan@gmail * Interpret zero-filled numbers as decimal; PR 4213; from Alexey Dobriyan
This commit is contained in:
10
histrap.c
10
histrap.c
@@ -1,9 +1,9 @@
|
||||
/* $OpenBSD: history.c,v 1.32 2005/12/11 18:53:51 deraadt Exp $ */
|
||||
/* $OpenBSD: history.c,v 1.34 2006/03/17 16:30:13 millert Exp $ */
|
||||
/* $OpenBSD: trap.c,v 1.22 2005/03/30 17:16:37 deraadt Exp $ */
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.14 2006/01/29 20:04:51 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.15 2006/05/10 18:54:10 tg Exp $");
|
||||
|
||||
static int histfd;
|
||||
static int hsize;
|
||||
@@ -63,7 +63,7 @@ c_fc(char **wp)
|
||||
}
|
||||
|
||||
while ((optc = ksh_getopt(wp, &builtin_opt,
|
||||
"e:glnrs0,1,2,3,4,5,6,7,8,9,")) != EOF)
|
||||
"e:glnrs0,1,2,3,4,5,6,7,8,9,")) != -1)
|
||||
switch (optc) {
|
||||
case 'e':
|
||||
p = builtin_opt.optarg;
|
||||
@@ -653,7 +653,9 @@ hist_init(Source *s)
|
||||
if ((fd = open(hname, O_RDWR|O_CREAT|O_APPEND, 0600)) < 0)
|
||||
return;
|
||||
|
||||
histfd = savefd(fd, 0);
|
||||
histfd = savefd(fd);
|
||||
if (histfd != fd)
|
||||
close(fd);
|
||||
|
||||
(void) flock(histfd, LOCK_EX);
|
||||
|
||||
|
Reference in New Issue
Block a user