vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Tue, May 16, 2006 at 10:52:47AM -0600, Theo de Raadt wrote: > Ok, so there is no \$ fix yet Oh sure, it's attached jmc was so kind to provide me with the POSIX for "Shell & Utilities" specs. It says: "2.2.2 Single-Quotes Enclosing characters in single-quotes ( '' ) shall preserve the literal value of each character within the single-quotes. A single-quote cannot occur within single-quotes." ksh does substitution on PS1 which was set in single quotes *again* in the PS1 routine, although substitution has been done already when a variable was set. Substituting a variable value again means doing it on a value *without* quotes, and this escapes special characters like \$. I set PS1 in single quotes and therefore I want to "preserve the literal value of each character", also for PS1. There is no special substitution case mentioned in POSIX for PS1. The attached diff removes the PS1 "extra" substitution and therefore fixes the \$ problem, and probably more problems if new PS1 special character commands are implemented. I don't know why this substitution is done again for PS1 in ksh. I think it even comes with the original version. *shrug* Regards, Marcus -- Marcus Glocker, marcus@nazgul.ch, http://www.nazgul.ch ----------------- diff -urN -x CVS src/bin/ksh.orig/ksh.1 src/bin/ksh/ksh.1 --- src/bin/ksh.orig/ksh.1 Sat Apr 22 16:10:36 2006 +++ src/bin/ksh/ksh.1 Thu May 18 23:04:17 2006 @@ -1647,7 +1647,6 @@ if the effective UID is 0, otherwise .Sq $ \& . -Note: this sequence is not yet implemented. .It Li \e Ns Ar nnn The octal character .Ar nnn . diff -urN -x CVS src/bin/ksh.orig/lex.c src/bin/ksh/lex.c --- src/bin/ksh.orig/lex.c Mon Apr 10 16:38:59 2006 +++ src/bin/ksh/lex.c Thu May 18 23:03:24 2006 @@ -1123,28 +1123,11 @@ void set_prompt(int to, Source *s) { - char *ps1; - Area *saved_atemp; - cur_prompt = to; switch (to) { case PS1: /* command */ - ps1 = str_save(str_val(global("PS1")), ATEMP); - saved_atemp = ATEMP; /* ps1 is freed by substitute() */ - newenv(E_ERRH); - if (sigsetjmp(e->jbuf, 0)) { - prompt = safe_prompt; - /* Don't print an error - assume it has already - * been printed. Reason is we may have forked - * to run a command and the child may be - * unwinding its stack through this code as it - * exits. - */ - } else - prompt = str_save(substitute(ps1, 0), - saved_atemp); - quitenv(NULL); + prompt = str_val(global("PS1")); break; case PS2: /* command continuation */ prompt = str_val(global("PS2")); @@ -1317,7 +1300,7 @@ snprintf(strbuf, sizeof strbuf, "%d", source->line + 1); break; - case '$': /* '\' '$' $ or # XXX busted */ + case '$': /* '\' '$' $ or # */ strbuf[0] = ksheuid ? '$' : '#'; strbuf[1] = '\0'; break; |