zsh-workers
 help / color / mirror / code / Atom feed
* Buffered stderr on Linux
@ 1996-03-12 19:03 Zoltan Hidvegi
  1996-03-12 19:24 ` Bart Schaefer
  0 siblings, 1 reply; 74+ messages in thread
From: Zoltan Hidvegi @ 1996-03-12 19:03 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: application/pgp, Size: 2092 bytes --]

^ permalink raw reply	[flat|nested] 74+ messages in thread
* History file locking?
@ 1996-04-10 10:31 Russell Senior
  1996-04-10 12:12 ` Zefram
  0 siblings, 1 reply; 74+ messages in thread
From: Russell Senior @ 1996-04-10 10:31 UTC (permalink / raw)
  To: zsh-workers


In order to keep Zsh from trashing its history file, I have
implemented the following local patch.  Perhaps this can be worked
into the source tree?  This patch uses the fcntl() function to lock
the entire contents of the history file during read and write
operations, using the corresponding blocking read and write locks. 

-- 
Russell Senior                                seniorr@teleport.com



*** hist.c-orig	Thu Dec 21 14:44:16 1995
--- hist.c	Wed Apr 10 03:22:35 1996
***************
*** 30,35 ****
--- 30,36 ----
   */
  
  #include "zsh.h"
+ #include <fcntl.h>
  
  extern int cs, ll;
  
***************
*** 1250,1255 ****
--- 1251,1262 ----
      time_t tim = time(NULL);
      short *wordlist;
      int nwordpos, nwordlist;
+     struct flock lk;
+ 
+     lk.l_type = F_RDLCK;
+     lk.l_whence = SEEK_SET;
+     lk.l_start = 0;
+     lk.l_len = 0;
  
      if (!s)
  	return;
***************
*** 1257,1262 ****
--- 1264,1271 ----
  	nwordlist = 16;
  	wordlist = (short *)zalloc(nwordlist*sizeof(short));
  
+         fcntl(fileno(in),F_SETLKW,&lk);
+         
  	while (fgets(buf, sizeof(buf), in)) {
  	    int l = strlen(buf);
  	    char *pt, *start;
***************
*** 1326,1333 ****
  	    } else
  		ent->words = (short *)NULL;
  	}
  	fclose(in);
! 
  	zfree(wordlist, nwordlist*sizeof(short));
      } else if (err)
  	zerr("can't read history file", s, 0);
--- 1335,1345 ----
  	    } else
  		ent->words = (short *)NULL;
  	}
+         
+         lk.l_type = F_UNLCK;
+         fcntl(fileno(in),F_SETLKW,&lk);
  	fclose(in);
!         
  	zfree(wordlist, nwordlist*sizeof(short));
      } else if (err)
  	zerr("can't read history file", s, 0);
***************
*** 1341,1347 ****
--- 1353,1364 ----
      FILE *out;
      int ev;
      Histent ent;
+     struct flock lk;
  
+     lk.l_whence = SEEK_SET;
+     lk.l_start = 0;
+     lk.l_len = 0;
+     
      if (!s || !interact || savehist == 0)
  	return;
      ev = curhist - savehist + 1;
***************
*** 1352,1357 ****
--- 1369,1376 ----
      else
  	out = fdopen(open(s, O_CREAT | O_WRONLY | O_TRUNC, 0600), "w");
      if (out) {
+         lk.l_type = F_WRLCK;
+         fcntl(fileno(out),F_SETLKW,&lk);
  	for (; ev <= curhist; ev++) {
  	    ent = gethistent(ev);
  	    if (app & 2) {
***************
*** 1374,1385 ****
--- 1393,1410 ----
  	    }
  	    fputc('\n', out);
  	}
+         
+         lk.l_type = F_UNLCK;
+         fcntl(fileno(out),F_SETLKW,&lk);
  	fclose(out);
  
  	if (app & 2 && (out = fopen(s, "r"))) {
  	    char **store, buf[1024], **ptr;
  	    int i, l, histnum = 0;
  
+             lk.l_type = F_WRLCK;
+             fcntl(fileno(out),F_SETLKW,&lk);
+ 
  	    store = (char **)zcalloc((savehist + 1) * sizeof *store);
  	    while (fgets(buf, sizeof(buf), out)) {
  		l = strlen(buf);
***************
*** 1394,1407 ****
--- 1419,1439 ----
  		strcpy(store[i], buf);
  		histnum++;
  	    }
+             lk.l_type = F_UNLCK;
+             fcntl(fileno(out),F_SETLKW,&lk);
  	    fclose(out);
  	    if ((out = fdopen(open(s, O_WRONLY | O_TRUNC, 0600), "w"))) {
+                 lk.l_type = F_WRLCK;
+                 fcntl(fileno(out),F_SETLKW,&lk);
+ 
  		if (histnum < savehist)
  		    for (i = 0; i < histnum; i++)
  			fprintf(out, "%s", store[i]);
  		else
  		    for (i = histnum; i < histnum + savehist; i++)
  			fprintf(out, "%s", store[i % savehist]);
+                 lk.l_type = F_UNLCK;
+                 fcntl(fileno(out),F_SETLKW,&lk);
  		fclose(out);
  	    }
  	    for (ptr = store; *ptr; ptr++)



^ permalink raw reply	[flat|nested] 74+ messages in thread
* Builtin append() and prepend() to PATH, CDPATH, etc.
@ 1996-06-02 17:59 Fung-Chai Lim
  1996-06-02 21:26 ` Zoltan Hidvegi
  0 siblings, 1 reply; 74+ messages in thread
From: Fung-Chai Lim @ 1996-06-02 17:59 UTC (permalink / raw)
  To: The Z-shell

Hi,

I have not check the documentation to see if this is already in zsh.
I have not even compile and install the latest version; zsh is evolving
too fast for me to catch up.

Anyway, I am referring to the shell functions named append() and
prepend() that I'd found in Sun's /usr/openwin/bin/openwin.

They are used to add components to colon-separated variables like
PATH, CDPATH, MANPATH, etc, and will only add the component if the
component is not already in the variable.

I would like to see these 2 capabilities built-in into the shell
with some syntactic sugar on top.

For example, zsh has `pushd_ignore_dups'.  I think it would be easy
to add a builtin function, say, `uniq-var' that, like `export', accept
a variable list of arguments.  An example is
	$ uniq-var PATH CDPATH MANPATH
After evaluating this statement, modifying any of the 3 variables
would ensure no duplication:
	$ set path = (/usr/local/bin $path /usr/bin)
would prepend /usr/local/bin and append /usr/bin into PATH only if
they are not already in it.

Having such features would help with the current lengthy and redundant
output with "echo $PATH".

Having them builtin would speed up the evaluation of .zprofile.

Thanks in advance.

Regards,
fclim.



^ permalink raw reply	[flat|nested] 74+ messages in thread
* BUG: useheap in doexpandhist()
@ 1996-06-22 20:12 Bart Schaefer
  0 siblings, 0 replies; 74+ messages in thread
From: Bart Schaefer @ 1996-06-22 20:12 UTC (permalink / raw)
  To: zsh-workers

I just got (in beta21):

	BUG: useheap in doexpandhist()

in the middle of completing the name of a zsh function.  It happened only
once, and I can't seem to make it happen again.

Possibly related --

In beta17 on IRIX, I can reliably crash zsh with the following sequence:

zsh% bindkey '\eq' push-line-or-edit
zsh% echo foo 'bar
> baz<ESC-q>
zsh% echo foo 'bar
baz<DEL><DEL><DEL><DEL>
zsh% echo foo 'bar'<RET>
foo bar
zsh% SA<TAB>
segmentation fault

(where SA can be any completion that will fail; I happened to be trying to
complete SAVEHIST, for reasons too obscure to go into).

I have automenu set, in case that matters; compctls are the defaults.

However, I can't crash beta21 on linux with that sequence.  I haven't had a
chance to compile beta21 on IRIX as yet.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"



^ permalink raw reply	[flat|nested] 74+ messages in thread
[parent not found: <17651.199607222123@stone.dcs.warwick.ac.uk>]
* Parameter expansion bug?
@ 1996-10-31 14:41 Anthony Heading
  1996-10-31 15:13 ` Hrvoje Niksic
  1996-10-31 16:12 ` Zoltan Hidvegi
  0 siblings, 2 replies; 74+ messages in thread
From: Anthony Heading @ 1996-10-31 14:41 UTC (permalink / raw)
  To: zsh-workers

This does not print anything (at least with zsh 3.0.0) - shouldn't it print `-'?

% echo ${dqkjdkqdq:--}

Anthony


^ permalink raw reply	[flat|nested] 74+ messages in thread
* fifo configure check
@ 1996-12-13  2:30 Zoltan Hidvegi
  0 siblings, 0 replies; 74+ messages in thread
From: Zoltan Hidvegi @ 1996-12-13  2:30 UTC (permalink / raw)
  To: Zsh hacking and development

I discovered that fifo test fails if zsh is compiled in an NFS mounted
directory.  The patch below shoud fix it (it's only for configure.in, you
need autoconf).  I did not test it but it should work.

Zoltan


*** configure.in	1996/12/05 03:59:45	3.1.0.10
--- configure.in	1996/12/13 02:27:32
***************
*** 656,680 ****
  {
      char c;
      int fd;
!     int pid;
!     unlink("conftestfifo");
  #ifdef HAVE_MKFIFO
!     if(mkfifo("conftestfifo", 0600) < 0)
  #else
!     if(mknod("conftestfifo", 0010600, 0) < 0)
  #endif
  	exit(1);
      pid = fork();
      if(pid < 0)
  	exit(1);
      if(pid) {
! 	fd = open("conftestfifo", O_RDONLY);
  	exit(fd < 0 || read(fd, &c, 1) != 1 || c != 'x');
      }
!     fd = open("conftestfifo", O_WRONLY);
!     if(fd < 0 || write(fd, "x", 1) < 1)
! 	kill(getppid(), SIGTERM);
!     exit(0);
  }
  ],
    zsh_cv_sys_fifo=yes,
--- 656,680 ----
  {
      char c;
      int fd;
!     int pid, ret;
!     unlink("/tmp/conftestfifo");
  #ifdef HAVE_MKFIFO
!     if(mkfifo("/tmp/conftestfifo", 0600) < 0)
  #else
!     if(mknod("/tmp/conftestfifo", 0010600, 0) < 0)
  #endif
  	exit(1);
      pid = fork();
      if(pid < 0)
  	exit(1);
      if(pid) {
! 	fd = open("/tmp/conftestfifo", O_RDONLY);
  	exit(fd < 0 || read(fd, &c, 1) != 1 || c != 'x');
      }
!     fd = open("/tmp/conftestfifo", O_WRONLY);
!     ret = (fd < 0 || write(fd, "x", 1) < 1);
!     unlink("/tmp/conftestfifo");
!     exit(ret);
  }
  ],
    zsh_cv_sys_fifo=yes,


^ permalink raw reply	[flat|nested] 74+ messages in thread
* history-search-backward
@ 1997-01-31 10:47 Peter Stephenson
  1997-01-31 12:16 ` history-search-backward Zefram
  1997-01-31 19:13 ` history-search-backward Wayne Davison
  0 siblings, 2 replies; 74+ messages in thread
From: Peter Stephenson @ 1997-01-31 10:47 UTC (permalink / raw)
  To: Zsh hackers list

Looks like another incompatibility got in while I wasn't paying much
attention: ^[p will only search backwards on complete words.  (I
remember the discussion, not the conclusion, I presume this is
intentional.)  It seems to me this is going to cause lots of zsh users
endless confusion when they type part of a word, then ^[p, and nothing
happens.

It's also incompatible with the tcsh binding (it always was a bit, but
not so drastically).  It makes it essentially useless for me, too,
since I use it as a way of abbreviating the first word of a command,
but that's personal taste and I can live with
history-beginning-search-backward.

<customary diatribe about incompatibilities deleted, you've seen it before>

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] 74+ messages in thread
* comptest* failed to load module: zsh/termcap
@ 2001-04-27 19:54 Peter Whaite
  2001-04-28  6:10 ` Bart Schaefer
  0 siblings, 1 reply; 74+ messages in thread
From: Peter Whaite @ 2001-04-27 19:54 UTC (permalink / raw)
  To: zsh-workers


Cvs last couple of days says after 'make test'

./Y01completion.ztst: starting.
comptestinit:10: failed to load module: zsh/termcap
comptestinit:echotc:10: autoload failed
./Y01completion.ztst: all tests successful.
./Y02compmatch.ztst: starting.
comptestinit:10: failed to load module: zsh/termcap
comptestinit:echotc:10: autoload failed
./Y02compmatch.ztst: all tests successful.
./Y03arguments.ztst: starting.
comptestinit:10: failed to load module: zsh/termcap
comptestinit:echotc:10: autoload failed
./Y03arguments.ztst: all tests successful.

Is this OK? 

--
peta


^ permalink raw reply	[flat|nested] 74+ messages in thread

end of thread, other threads:[~2001-04-30 19:13 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-12 19:03 Buffered stderr on Linux Zoltan Hidvegi
1996-03-12 19:24 ` Bart Schaefer
1996-03-12 20:26   ` Zoltan Hidvegi
1996-03-12 23:17   ` Zoltan Hidvegi
1996-03-13  0:16     ` Steven L Baur
     [not found]     ` <hzoli@cs.elte.hu>
1996-03-16 18:46       ` Bart Schaefer
1996-04-10 21:41       ` History file locking? Barton E. Schaefer
1996-04-10 22:16         ` Daniel Dignam
1996-06-26 13:51       ` Use of qualifiers without glob pattern? Bart Schaefer
1996-06-26 14:01         ` Regression tests Bas V. de Bakker
1996-06-26 14:52         ` Use of qualifiers without glob pattern? Zoltan Hidvegi
1996-06-26 15:54           ` Bart Schaefer
1996-06-27  1:03             ` Zoltan Hidvegi
1996-10-31 16:55       ` Parameter expansion bug? Bart Schaefer
1996-10-31 16:57         ` Hrvoje Niksic
1996-10-31 17:04         ` Zoltan Hidvegi
1996-10-31 17:47           ` Bart Schaefer
1996-12-13  3:37       ` fifo configure check Bart Schaefer
1996-12-13  8:58         ` fifo configure check (seems to work here: Solaris 2.4) C. v. Stuckrad
1996-12-13 14:44         ` fifo configure check Zefram
1996-12-13 17:33           ` Zoltan Hidvegi
     [not found]       ` <wayne@clari.net>
1997-01-31 22:01         ` history-search-backward Bart Schaefer
1996-04-10 10:31 History file locking? Russell Senior
1996-04-10 12:12 ` Zefram
1996-04-10 12:41   ` Zoltan Hidvegi
1996-04-10 12:50     ` Zefram
     [not found]       ` <A.Main@dcs.warwick.ac.uk>
1996-04-10 16:26         ` Barton E. Schaefer
1996-04-10 17:08           ` Anthony Heading
     [not found]             ` <aheading@jpmorgan.com>
1996-04-10 17:12               ` Barton E. Schaefer
1996-04-10 18:03                 ` Anthony Heading
1996-06-05 21:25         ` Builtin append() and prepend() to PATH, CDPATH, etc Bart Schaefer
     [not found]           ` <schaefer@candle.brasslantern.com>
1996-06-10 19:22             ` Clinton Bunch
1996-06-10 19:54               ` Bart Schaefer
1996-06-10 20:24                 ` Hrvoje Niksic
1996-06-10 20:58             ` Clinton Bunch
1996-06-24 18:26             ` BUG: useheap in doexpandhist() Barton E. Schaefer
1996-06-24 19:11               ` Zoltan Hidvegi
1996-06-24 21:20                 ` Barton E. Schaefer
1996-06-25  0:01                   ` Zoltan Hidvegi
1996-06-25  0:22                     ` Barton E. Schaefer
1996-07-23 20:01             ` Bug in case stmt with '(' Morris M. Siegel
1996-07-23 21:55               ` Bart Schaefer
1996-07-24  8:29                 ` Zefram
1996-07-24  9:52                 ` Peter Stephenson
1996-07-24 11:10         ` Bart Schaefer
1996-07-24 14:16           ` Zoltan Hidvegi
1996-04-10 21:21       ` History file locking? Zoltan Hidvegi
1996-06-02 17:59 Builtin append() and prepend() to PATH, CDPATH, etc Fung-Chai Lim
1996-06-02 21:26 ` Zoltan Hidvegi
     [not found]   ` <1062.199606041027@stone.dcs.warwick.ac.uk>
1996-06-22 20:12 BUG: useheap in doexpandhist() Bart Schaefer
     [not found] <17651.199607222123@stone.dcs.warwick.ac.uk>
1996-07-23 14:08 ` Bug in case stmt with '(' Zoltan Hidvegi
1996-07-23 16:25   ` Bart Schaefer
1996-10-31 14:41 Parameter expansion bug? Anthony Heading
1996-10-31 15:13 ` Hrvoje Niksic
1996-10-31 16:12 ` Zoltan Hidvegi
1996-10-31 20:49   ` Anthony Heading
1996-12-13  2:30 fifo configure check Zoltan Hidvegi
1997-01-31 10:47 history-search-backward Peter Stephenson
1997-01-31 12:16 ` history-search-backward Zefram
1997-01-31 12:42   ` history-search-backward Peter Stephenson
1997-01-31 15:02     ` history-search-backward Bart Schaefer
1997-01-31 15:23       ` history-search-backward Vinnie Shelton
1997-01-31 19:02     ` history-search-backward Zoltan Hidvegi
1997-01-31 19:13 ` history-search-backward Wayne Davison
2001-04-27 19:54 comptest* failed to load module: zsh/termcap Peter Whaite
2001-04-28  6:10 ` Bart Schaefer
2001-04-28  8:55   ` Andrej Borsenkow
2001-04-30 15:44     ` Peter Whaite
2001-04-30 16:30       ` Bart Schaefer
2001-04-30 16:47         ` Andrej Borsenkow
2001-04-30 17:16           ` PATCH: " Bart Schaefer
2001-04-30 18:54         ` Peter Whaite
2001-04-30 19:12           ` Bart Schaefer
2001-04-30 15:32   ` Peter Whaite

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).