zsh-users
 help / color / mirror / code / Atom feed
* Why this doesn't work?
@ 2005-03-12 10:14 DervishD
  2005-03-12 20:49 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: DervishD @ 2005-03-12 10:14 UTC (permalink / raw)
  To: Zsh Users

    Hi all :))

    I have a problem with quoting and 'eval'. I know that, withing
double quotes, the '\' is a quoting char only if followed by '\','$',
'"', ''' and newline, otherwise is a literal backslash. This allow
for this:

    $ printf -- "Hello\n"
    Hello<newline>

    In that expression, the '\' is a literal '\', no problem. The
problema arises when:

    $ eval printf -- "Hello\\n"
    Hello$
    $ eval printf -- "Hello\\\n"
    Hello<newline>

    I mean, no newline character is output when using just two
backslashes, and I don't understand that. In the first case, with two
backslashes, I think that the shell interprets it as 'Hello' plus
'\\' (that is, a backslash) and a 'n', so the shell runs a command
like: 'printf -- "Hello\n"'. Obviously, it doesn't.

    The second example, as I understand it, should expand to:

    printf -- "Hello\\n"

    that is, "Hello" plus "\\" plus "\n". If the double-quotes rule
is not followed in 'eval' commands, it should expand to "Hello" plus
"\\" resulting in one "\" and "\n" resulting in "n", but then in the
example with just two backslashes it should expand to "Hello" plus
"\\" resulting in "\" and a "n", that is, the same. And obviously is
not. What am I missing?

    I always use three backslases in 'eval' commands because sometime
in the past I learned why, but I've forgotten, sorry O:))) Anyone
could help?

    Thanks a lot in advance :)

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


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

end of thread, other threads:[~2005-03-14 10:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-12 10:14 Why this doesn't work? DervishD
2005-03-12 20:49 ` Bart Schaefer
2005-03-13  9:39   ` Why this expansion " DervishD
2005-03-13 17:16     ` Bart Schaefer
2005-03-14 10:50       ` DervishD

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).