You are not logged in.

#1 2010-11-04 12:56:12

proc
Member
From: Italy
Registered: 2006-11-27
Posts: 71

zsh command line and percent sign (not prompt)

Hi,

I'm having problems finding a method to "escape" percent signs in a ZSH command line: i.e.

stat --format='%a %g %U' ~/test

%U gets interpreted by zsh (zle?) and mess with the output of the command.

I tried to use backspace, single and double quotes around %, but I didn't menage to make ZSH ignore it.
Is there any option that needs to be set?

Thanks

Offline

#2 2010-11-04 13:35:50

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: zsh command line and percent sign (not prompt)

Not familiar with ZSH, but generally when % are being used in a printf manner, you use %% to print a literal one.

http://www.acm.uiuc.edu/workshops/zsh/p … capes.html

Offline

#3 2010-11-04 14:08:51

proc
Member
From: Italy
Registered: 2006-11-27
Posts: 71

Re: zsh command line and percent sign (not prompt)

Unfortunately %% doesn't work, since stat will not interpret what I want it to print... this is something specific to ZSH.

Thanks for your prompt reply, nonetheless.

Offline

#4 2010-11-04 14:53:47

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: zsh command line and percent sign (not prompt)

Try replacing the single quotes with double quotes:

barrucadu on azathoth in ~ [branch: master]
 >>>  stat --format="%a %g %U" ~                                                                                                                                                                                                                                                  
700 100 barrucadu

Offline

#5 2010-11-04 14:56:32

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: zsh command line and percent sign (not prompt)

That command works here.

stat --format='%a %g %U' ~/inte
700 1000 milo

I even tried with ROOT user that has no zshrc. Same result. Maybe you have a globbing option set/unset?

read 'manpage zshoptions'
And try:

setopt

This will show options that are Set which are NOT default.
You can also type:

setopt kshoptionprint
setopt

And see what is set and isn't set, compare to manpage descriptions.

Here's what I have with 'nokshoptionprint' and typing 'setopt':

alwaystoend
autocd
autocontinue
autonamedirs
autopushd
nobeep
bsdecho
chaselinks
noclobber
completealiases
completeinword
correct
cshjunkieloops
extendedglob
noglobalexport
noglobalrcs
globdots
nohistbeep
histexpiredupsfirst
histfindnodups
histignoredups
histignorespace
histnofunctions
histnostore
histreduceblanks
nohistsavebycopy
histverify
incappendhistory
interactive
nolistbeep
listpacked
login
longlistjobs
markdirs
numericglobsort
promptbang
promptsubst
pushdignoredups
shinstdin
vi
warncreateglobal

So these are NOT default and they're set.

But again, the command even works with users that have no .zshrc file.. for me anyway.

Last edited by milomouse (2010-11-04 14:57:47)

Offline

#6 2010-11-05 09:34:23

proc
Member
From: Italy
Registered: 2006-11-27
Posts: 71

Re: zsh command line and percent sign (not prompt)

Milomouse thanks for your suggestions... indeed I should have tried not loading .zshrc

I found the cause of the problem:

case $TERM in
         xterm*)
            precmd() { print -Pn "\e]0;%n@%m:%~\a" }
            preexec () { print -Pn "\e]0;$1 %n@%m\a" }
            ;;
esac

Everything is ok if I remove $1 from the preexec function, but I want to see the job name in the window's title.

Any ideas?

Offline

#7 2010-11-12 21:04:00

JokerBoy
Member
From: România
Registered: 2009-09-24
Posts: 641

Re: zsh command line and percent sign (not prompt)

not quite..

try also: echo -n "1\n2"

Offline

#8 2011-07-13 10:05:12

quatrix
Member
Registered: 2011-07-13
Posts: 7

Re: zsh command line and percent sign (not prompt)

I saw this post only now.

'%' is what is creating problems. Use ${~1:gs/%/%%} instead of $1 to quote it.

Offline

#9 2011-07-13 11:51:18

proc
Member
From: Italy
Registered: 2006-11-27
Posts: 71

Re: zsh command line and percent sign (not prompt)

Thanks a lot!

Offline

Board footer

Powered by FluxBB