zsh-users
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <Vincent.Lefevre@ens-lyon.fr>
To: john.cooper@digitivity.com
Cc: zsh-users@math.gatech.edu
Subject: Re: backslash problems?
Date: Mon, 27 Oct 1997 13:36:34 +0100	[thread overview]
Message-ID: <19971027133634.59572@ens-lyon.fr> (raw)
In-Reply-To: <19971027113104140.AAA348@TENDLE>; from John Cooper on Mon, Oct 27, 1997 at 11:31:05AM +0000

On Mon, Oct 27, 1997 at 11:31:05AM +0000, John Cooper wrote:
> $ echo "foo\bar\baz"
> foaaz

Inside double quotes, "b" is already quoted, so "\b" evaluates to \b,
and "foo\bar\baz" evaluates to foo\bar\baz. Then, through zsh's echo,
\b evaluates to backspace (man zshbuiltins) by default. This explains
what is displayed.

> $ echo "foo\\bar\\baz"
> foaaz

Even inside double quotes, "\\" evaluates to a single backslash (this
allows to use \" and \$ inside double quotes). So, "foo\\bar\\baz"
evaluates to foo\bar\baz like in the first case. Therefore you get
the same result as above.

> $ echo 'foo\bar\baz'
> foaaz

Same as in the first case.

> $ echo 'foo\\bar\\baz'
> foo\bar\baz

Inside single quotes, '\\' evaluates to \\. And then, \\ evaluates
to a single backslash.

> Under bash, it seems more consistent:
> 
> $ bash
> bash$ echo "foo\bar\baz"
> foo\bar\baz
> bash$ echo 'foo\bar\baz'
> foo\bar\baz
> bash$

You'll get the same behavior if you use the switch -E with zsh's echo.

man zshbuiltins, command echo gives:

          The -E falg or the BSD_ECHO option can be used to  dis-
          able  these escape sequences. In the later case -e flag
          can be used to enable them.

**** Zsh writers: there's a typo ("falg" instead of "flag").

-- 
Vincent Lefevre <vlefevre@ens-lyon.fr> | Acorn Risc PC, StrongARM @ 202MHz
WWW: http://www.ens-lyon.fr/~vlefevre/ | 20+1MB RAM, Eagle M2, TV + Teletext
PhD st. in Computer Science, 2nd year  | Apple CD-300, SyQuest 270MB (SCSI)
-----------------------------------------------------------------------------


      parent reply	other threads:[~1997-10-27 12:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-27 11:31 John Cooper
1997-10-27 11:53 ` Andrew Main
1997-10-27 12:36 ` Vincent Lefevre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19971027133634.59572@ens-lyon.fr \
    --to=vincent.lefevre@ens-lyon.fr \
    --cc=john.cooper@digitivity.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).