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 Tue, 23 May 2006, Marcus Glocker wrote: > On Tue, May 23, 2006 at 09:07:04PM +0200, Otto Moerbeek ...


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 Tue, 23 May 2006, Marcus Glocker wrote:

> On Tue, May 23, 2006 at 09:07:04PM +0200, Otto Moerbeek wrote:
>
> > Care to explain? For PS1, posix describes:
> >
> > "PS1 Each time an interactive shell is ready to read a command, the value
> > of this variable shall be subjected to parameter expansion and written
> > to standard error."

>
> "2.2.3 Double Quotes
> The backslash shall retain its special meaning as an escape character
> only when followed by one of the following characters when
> considered sepcial:
> $ ` " \ <newline>"
>
> PS1="$x$(print \\r)$x$(tput so)$x\$PWD$x$(tput se)$x> "
>
> In my understanding escaping \$PWD in double quotes should result
> in $PWD because $ got escaped and looses its meaning as a variable
> holder. So I would assume to just set $PWD in double quotes, which
> still works with my diff applied.


But how exactly? The example puts the current wd in the prompt.

Let's use a more simple example with the current ksh:

PS1="\$PWD "

there are two moments variable substitution takes place. The first is
when assigning to PS1. The \ is needed to avoid immediate expansion
of $PWD, since you want to do that each time a new prompt is
displayed, the piece from posix I quoted earlier says that should be
done each time a prompt is displayed.

So after assigning PS1, it holds the string '$PWD ', which will be
expanded each time a prompt is printed and so have the desired effect
of printing the current wd.

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.

-Otto

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 01:19 AM.


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