summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2006-06-16 20:34:23 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2006-06-16 20:34:23 +0000
commit79bd9a674564ac4adf8ee6b531cc5c5a4a68f37a (patch)
treea3a8b5deec091943636903c26088b2728d76bcc9 /bin
parent86c6a233dbaca49f88a2a557c884d9ff72d429b0 (diff)
Work around a problem with \$ expansion where \$\$ turned into pid ($$)
expansion. otto and I cannot think of anything better. ok otto@
Diffstat (limited to 'bin')
-rw-r--r--bin/ksh/lex.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c
index db5392f434f..75b44539f66 100644
--- a/bin/ksh/lex.c
+++ b/bin/ksh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.40 2006/05/29 18:22:24 otto Exp $ */
+/* $OpenBSD: lex.c,v 1.41 2006/06/16 20:34:22 drahn Exp $ */
/*
* lexical analysis and source input
@@ -1128,8 +1128,7 @@ special_prompt_expand(char *str)
char *p = str;
while ((p = strstr(p, "\\$")) != NULL) {
- memmove(p, p + 1, strlen(p));
- *p = ksheuid ? '$' : '#';
+ *(p+1) = 'p';
}
return str;
}
@@ -1259,6 +1258,10 @@ dopprompt(const char *sp, int ntruncate, const char **spp, int doprint)
totlen = 0; /* reset for prompt re-print */
sp = cp + 1;
break;
+ case 'p': /* '\' '$' $ or # */
+ strbuf[0] = ksheuid ? '$' : '#';
+ strbuf[1] = '\0';
+ break;
case 'r': /* '\' 'r' return */
strbuf[0] = '\r';
strbuf[1] = '\0';