Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Why this expansion doesn't work?



    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> } > What you should see is "Hellon", not "Hello".
> }     That's weird :(( I still have open the console where I saw that,
> } but in a new virtual console that doesn't happen
> Cosmic rays.

    I'm seriouly thinking about that XDDD Probably the cause have
been the cosmic rays... hitting my brain. Or my poor eye quality, who
knows...
 
> } > The first parse removes the quotes and one of the backslashes, and the
> } > second parse removes the remaining backslash.
> }     So I must use something like:
> }     eval printf -- \"Hello\\n\"
> Yes, except of course that means something considerably different when
> there are spaces or metacharacters in the (no longer double-quoted on
> the first parse) string.  More likely you want
> 
> 	eval printf -- \""Hello\\n"\"

    Errr... yes. I'll fix it right now. I'm using this in a script
and in a couple of places I think I'll need double quotes (in
addition to the quoted ones...).
 
> }     I forgot that the double quotes were removed :((( Is there any
> } way of seeing how a command line is parsed *just before* being
> } executed by the shell?
> setopt xtrace

    I forgot. I use xtrace to see the progress in scripts, but I
never used it for seeing expansions O:) Thanks a lot for the advice.
 
> (or the equivalent "set -x").  Note that xtrace in recent versions of
> zsh re-quotes the output so that it's suitable for cut-and-paste; old
> versions (4.0.x and before) show the fully-unquoted result, but there
> it's difficult to see where the shell split strings into words.

    I'm using 4.2.x now.

> So e.g.
> 
> zagzig% set -x
> zagzig% eval printf -- \""Hello\\n"\"
> +Src/zsh:2> eval printf -- '"Hello\n"'
> +(eval):1> printf -- 'Hello\n'
> Hello
> zagzig% 

    Nice :)) Thanks a lot, Bart. You're fantastic :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...



Messages sorted by: Reverse Date, Date, Thread, Author