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; --> On Thu, 18 May 2006, Marcus Glocker wrote: > On Tue, May 16, 2006 at 10:52:47AM -0600, Theo de ...


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

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

On Thu, 18 May 2006, Marcus Glocker wrote:

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


your diff breaks this example from the man page:

x=$(print \\001)
PS1="$x$(print \\r)$x$(tput so)$x\$PWD$x$(tput se)$x> "

-Otto

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


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 02:37 AM.


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