This is a discussion on Re: ksh diff, part II within the mailing.openbsd.tech forums, part of the OpenBSD category; --> > With your diff, the expansion will be done only once, on the initial > assignment of PS1. I ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| > With your diff, the expansion will be done only once, on the initial > assignment of PS1. I do not see how you'd get the current working dir > in a prompt with your diff. And what's more, I do not see how the > current behaviour is non-posix, as you claim. Yes, you are right and I am wrong. Sorry about that. I was confused why it is saying PS1="$x$(print \\r)$x$(tput so)$x\$PWD$x$(tput se)$x> " and not directly PS1='$x$(print \\r)$x$(tput so)$x$PWD$x$(tput se)$x> ' but in the end both has the same effect. And after reading that posix quote again, you are also right, it *shall* be parameter expanded, which gets lost with my last diff. How about this diff. I've updated the regression test a bit which you can fetch here: http://www.nazgul.ch/dev/ksh_regress.tar.gz Regards, Marcus -- Marcus Glocker, marcus@nazgul.ch, http://www.nazgul.ch ----------------- 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 25 15:53:14 2006 @@ -67,6 +67,7 @@ static int backslash_skip; static int ignore_backslash_newline; +static int ps1_flag; /* optimized getsc_bn() */ #define getsc() (*source->str != '\0' && *source->str != '\\' \ @@ -288,6 +289,18 @@ switch (c) { case '\\': c = getsc(); + /* + * For currently active PS1 string don't do + * escape character substitution anymore + * for those characters which are used in + * dopprompt() + */ + if (ps1_flag) { + if (c == '$') { + *wp++ = '\\', *wp++ = c; + break; + } + } switch (c) { case '\\': case '$': case '`': @@ -1141,9 +1154,12 @@ * unwinding its stack through this code as it * exits. */ - } else + } else { + ps1_flag = 1; prompt = str_save(substitute(ps1, 0), saved_atemp); + ps1_flag = 0; + } quitenv(NULL); break; case PS2: /* command continuation */ |