about summary refs log tree commit diff
path: root/Src/hist.c
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-06 18:01:35 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-06 18:01:35 +0000
commit784c413690c71212ad9e08bb093414abd1cacc08 (patch)
tree450cc9242047dd50255af3b1ef940dae5bb3ab39 /Src/hist.c
parent61e68d70da5af5afe943f92cd94a8c96e78348d9 (diff)
downloadzsh-784c413690c71212ad9e08bb093414abd1cacc08.tar.gz
zsh-784c413690c71212ad9e08bb093414abd1cacc08.tar.xz
zsh-784c413690c71212ad9e08bb093414abd1cacc08.zip
zsh-3.1.6-pws-1 zsh-3.1.6-pws-1
Diffstat (limited to 'Src/hist.c')
-rw-r--r--Src/hist.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 52e3e1394..8d8fba4af 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -577,6 +577,18 @@ histsubchar(int c)
 	    case 'q':
 		quote(&sline);
 		break;
+	    case 'Q':
+		{
+		    int one = noerrs, oef = errflag;
+
+		    noerrs = 1;
+		    parse_subst_string(sline);
+		    noerrs = one;
+		    errflag = oef;
+		    remnulargs(sline);
+		    untokenize(sline);
+		}
+		break;
 	    case 'x':
 		quotebreak(&sline);
 		break;
@@ -1947,6 +1959,7 @@ lockhistfile(char *fn, int keep_trying)
 	int fd, len = strlen(fn);
 	char *tmpfile, *lockfile;
 
+#ifdef HAVE_LINK
 	tmpfile = zalloc(len + 10 + 1);
 	sprintf(tmpfile, "%s.%ld", fn, (long)mypid);
 	if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_EXCL, 0644)) >= 0) {
@@ -1973,6 +1986,21 @@ lockhistfile(char *fn, int keep_trying)
 	}
 	unlink(tmpfile);
 	free(tmpfile);
+#else /* not HAVE_LINK */
+	lockfile = zalloc(len + 5 + 1);
+	sprintf(lockfile, "%s.LOCK", fn);
+	while ((fd = open(lockfile, O_CREAT|O_EXCL, 0644)) < 0) {
+		if (errno == EEXIST) continue;
+		else if (keep_trying) {
+		    if (time(NULL) - sb.st_mtime < 10)
+			sleep(1);
+		    continue;
+		}
+		lockhistct--;
+		break;
+	}
+	free(lockfile);
+#endif /* HAVE_LINK */
     }
     return ct != lockhistct;
 }