zsh-users
 help / color / mirror / code / Atom feed
* Re: Preexec & Printf
@ 2002-04-26  1:07 Joshua Symons
  2002-04-26  1:16 ` Bart Schaefer
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Symons @ 2002-04-26  1:07 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

From: Bart Schaefer <schaefer@brasslantern.com>
Date: Thursday, April 25, 2002 8:01 pm
Subject: Re: Preexec & Printf

> On Thu, 25 Apr 2002, Joshua Symons wrote:
> 
> > I have a pretty generic problem, but I can't seem to make my way 
> around> it.
> 
> Re-read the documentation for the preexec function.  In particular:
> 
> > preexec () {
> >         print -Pn "\e]0;%m:%l   -   $* \a"
> > }
> 
> You almost certainly want to refer to $1 rather than to $*.  To 
> remove the
> quotes from the string, you probably want to use ${(z)1}.
> 
> > $ZSH_VERSION = 3.1.9
> 
> You might also want to upgrade to zsh 4.0.4, which has been out for a
> while now.
> 
> 

Same results:
[(ichirou:151:pts/33)~ %] which preexec
preexec () {
        print -Pn "\e]0;%m:%l   -   ${(z)1} \a"
}
[(ichirou:152:pts/33)~ %] printf '^[[32;40mwith quotes\n' 
[32;40mwith quotes
' with quotes
[(ichirou:153:pts/33)~ %] unfunction preexec
[(ichirou:154:pts/33)~ %] printf '^[[32;40mwith quotes\n' 
with quotes

Additionally, I will upgrade to 4.0.4 as well, but I don't believe that
will fix this current issue.

-Josh-


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Preexec & Printf
@ 2002-04-26  2:10 Joshua Symons
  0 siblings, 0 replies; 14+ messages in thread
From: Joshua Symons @ 2002-04-26  2:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

Thx for all the help Geoff & Bart. 
I think I'll just stick with ${(qV)1} for now and change if necessary,
it appears to be working with everything. I'll try switching to ${(qV)2}
if I switch up to 4.0.4. Thx again.

- Josh -

----- Original Message -----
From: Bart Schaefer <schaefer@brasslantern.com>
Date: Thursday, April 25, 2002 9:06 pm
Subject: Re: Preexec & Printf

> On Thu, 25 Apr 2002, Joshua Symons wrote:
> 
> > ${(qV)1} appears to be doing the job in 3.1.9, in 3.0.8 (the version
> > that comes with solaris 9) or 3.0.6 (the version that comes with 
> solaris> 8) it gives a syntax error.
> > However with ${(QV)1} I still get garbage into my shell.
> 
> ${(q)...} adds a level of quoting, and ${(Q)...} removes a level.  Per
> Geoff's message, the (q) is "working" because it quotes the 
> backslashesand so forth, protecting e.g. \a from being emitted as 
> control-G by print.
> 
> However, what you said you wanted was to remove the quotes, so 
> that's why
> I suggested (Q).  That doesn't solve the backslashing problem.
> 
> You could try ${(q)${QV)1}} which would first remove the quotes and 
> thenescape the backslashes, or you can stick with just ${(qV)1}.
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Preexec & Printf
@ 2002-04-26  1:54 Joshua Symons
  2002-04-26  2:06 ` Bart Schaefer
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Symons @ 2002-04-26  1:54 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

${(qV)1} appears to be doing the job in 3.1.9, in 3.0.8 (the version
that comes with solaris 9) or 3.0.6 (the version that comes with solaris
8) it gives a syntax error.
However with ${(QV)1} I still get garbage into my shell.

[(ichirou:38:pts/22)~ %] which preexec
preexec () {
        print -Pn "\e]0;%m:%l   -   ${(QV)1} \a"
}
[(ichirou:39:pts/22)~ %] printf '^[[32;40mwith
quotes\n'                    
                                                         
  with quotes
[(ichirou:40:pts/22)~ %] 

[(ichirou:40:pts/22)~ %] which preexec
preexec () {
        print -Pn "\e]0;%m:%l   -   ${(qV)1} \a"
}
[(ichirou:41:pts/22)~ %] printf '^[[32;40mwith quotes\n' 
with quotes
[(ichirou:42:pts/22)~ %] 

- Josh -

----- Original Message -----
From: Bart Schaefer <schaefer@brasslantern.com>
Date: Thursday, April 25, 2002 8:45 pm
Subject: Re: Preexec & Printf

> On Thu, 25 Apr 2002, Joshua Symons wrote:
> 
> > I had seen q in the modifier list @
> > http://zsh.sourceforge.net/Doc/Release/zsh_13.html#SEC45
> > I don't see V and z in the modifier list, are they documented?
> 
> Unfortunately that's still the 3.0 -- or perhaps it's 3.1.6 --
> documentation.  You need to read the docs that came with your zsh
> distribution if you want accurate information.
> 
> > Additionally, where is the $* vs $1 documented, since I'm 
> accustomed to
> > $*.
> 
> The 3.1.9 doc (which I just happen to have lying around) says under 
> thepreexec function:
> 
>     ... If the history mechanism is active, the string to be
>     executed is passed as an argument.
> 
> Note "as AN argument", that is, the first and in this case only 
> argument,which is $1.  $* means all the arguments.
> 
> In 4.0.4, this has changed:
> 
>     ... If the history mechanism is active (and the line was not
>     discarded from the history buffer), the string that the user 
> typed     is passed as the first argument, otherwise it is an empty 
> string.     The actual command that will be executed (including 
> expanded     aliases) is passed in two different forms: the second 
> argument is
>     a single-line, size-limited version of the command (with things
>     like function bodies elided); the third argument contains the 
> full     text what what is being executed.
> 
> So in 4.0.4 if you use $* you'll get the command repeated three times,
> which is definitely not what you want.  If you had 4.0.4, you'd 
> probablywant ${(QV)2} or maybe just ${(V)2}.
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Preexec & Printf
@ 2002-04-26  1:31 Joshua Symons
  2002-04-26  1:47 ` Geoff Wing
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Symons @ 2002-04-26  1:31 UTC (permalink / raw)
  To: mason; +Cc: zsh-users

----- Original Message -----
From: Geoff Wing <mason@primenet.com.au>
Date: Thursday, April 25, 2002 8:22 pm
Subject: Re: Preexec & Printf

> Joshua Symons <vmcore@mysun.com> typed:
> : I have a pretty generic problem, but I can't seem to make my way 
> around: it. Here is an example of what is happening:
> 
> : [(ichirou:151:pts/15)~ %] which preexec
> : preexec () {
> :         print -Pn "\e]0;%m:%l   -   $* \a"
> :}
> : [(ichirou:152:pts/15)~ %] printf '^[[32;40mwith quotes\n'
> 
> : For echo, print, and printf, my '' is getting passed (straight 
> quote): into preexec and erroring back out into my shell. I can't 
> seem to get
> : around the quotes that are passed into preexec. This doesn't 
> happen in
> : dtterm for some reason, not sure why. 
> : Any help that could be given would be nice.
> 
> Your problem is different to what you think.  You're using xterm and
> you're expecting it to not print the set of characters sent through 
> thepreexec without consideration of what characters are permissible.
> Obviously you'll have problems if you try to send a BEL (\a) via the

I was actually using the example provided in the xterm title setting
how-to.
Is there a better way to terminate the title?

> normal line because it'll terminate the title-set OSC in the print 
> in the

OSC ?

> preexec().  You'll also have problems with xterm with other non-
> printablecharacters, e.g. ESC, CR, LF - xterm will also use those 
> as terminators
> since they're non-valid.  You'll need to do some more character
> sanitisation first on the string sent via the preexec() print.
> 
> Regards,
> -- 
> Geoff Wing : <gcw@pobox.com>
> Rxvt Stuff : <gcw@rxvt.org>
> Zsh Stuff  : <gcw@zsh.org>
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Preexec & Printf
@ 2002-04-26  1:25 Joshua Symons
  2002-04-26  1:45 ` Bart Schaefer
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Symons @ 2002-04-26  1:25 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

I had seen q in the modifier list @
http://zsh.sourceforge.net/Doc/Release/zsh_13.html#SEC45
and had tried that, but it still had the same problem with ${(q)*}, and
I don't see V and z in the modifier list, are they documented?
Additionally, where is the $* vs $1 documented, since I'm accustomed to
$*. Thx btw, it is working correctly now, I really appreciate it.

- Josh -

----- Original Message -----
From: Bart Schaefer <schaefer@brasslantern.com>
Date: Thursday, April 25, 2002 8:16 pm
Subject: Re: Preexec & Printf

> On Thu, 25 Apr 2002, Joshua Symons wrote:
> 
> > preexec () {
> >         print -Pn "\e]0;%m:%l   -   ${(z)1} \a"
> > }
> > [(ichirou:152:pts/33)~ %] printf '^[[32;40mwith quotes\n'
> > [32;40mwith quotes
> > ' with quotes
> 
> Your specific problem there is that the titlebar escape sequence 
> appearsliterally in the command that you're trying to put into the 
> titlebar, so
> strange things happen.  I missed that before.  Try ${(qVz)1}.
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Preexec & Printf
@ 2002-04-26  0:47 Joshua Symons
  2002-04-26  1:01 ` Bart Schaefer
  2002-04-26  1:22 ` Geoff Wing
  0 siblings, 2 replies; 14+ messages in thread
From: Joshua Symons @ 2002-04-26  0:47 UTC (permalink / raw)
  To: zsh-users

I have a pretty generic problem, but I can't seem to make my way around
it. Here is an example of what is happening:

[(ichirou:151:pts/15)~ %] which preexec
preexec () {
        print -Pn "\e]0;%m:%l   -   $* \a"
}
[(ichirou:152:pts/15)~ %] printf '^[[32;40mwith quotes\n'
[32;40mwith quotes
' with quotes
[(ichirou:153:pts/15)~ %] unfunction preexec
[(ichirou:154:pts/15)~ %] printf '^[[32;40mwith quotes\n'
with quotes
[(ichirou:155:pts/15)~ %] 

For echo, print, and printf, my '' is getting passed (straight quote)
into preexec and erroring back out into my shell. I can't seem to get
around the quotes that are passed into preexec. This doesn't happen in
dtterm for some reason, not sure why. 
Any help that could be given would be nice.

System Information:
SunOS ichirou 5.8 Generic_108528-12 sun4u sparc SUNW,Ultra-30
$ZSH_VERSION = 3.1.9

thx in advance
-Josh-


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-04-26  9:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-26  1:07 Preexec & Printf Joshua Symons
2002-04-26  1:16 ` Bart Schaefer
2002-04-26  1:19   ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2002-04-26  2:10 Joshua Symons
2002-04-26  1:54 Joshua Symons
2002-04-26  2:06 ` Bart Schaefer
2002-04-26  1:31 Joshua Symons
2002-04-26  1:47 ` Geoff Wing
2002-04-26  1:25 Joshua Symons
2002-04-26  1:45 ` Bart Schaefer
2002-04-26  9:21   ` Oliver Kiddle
2002-04-26  0:47 Joshua Symons
2002-04-26  1:01 ` Bart Schaefer
2002-04-26  1:22 ` Geoff Wing

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).