Unix Technical Forum

Re: ksh diff, part II

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 08:38 AM
Marcus Glocker
 
Posts: n/a
Default Re: ksh diff, part II

> 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 */

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:04 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com