dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Bosco <jbosco.gg@gmail.com>
Cc: dash@vger.kernel.org
Subject: Re: echo "\\1"?
Date: Thu, 27 Jul 2017 10:19:15 -0500	[thread overview]
Message-ID: <bdcef3ab-073b-370b-011d-fc918210b568@redhat.com> (raw)
In-Reply-To: <CAC4gepdMmWSdheZbfw44fn3eexJ4Wg3gSkj7pMChLNodB3UyTw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1315 bytes --]

On 07/27/2017 10:10 AM, Bosco wrote:
> That script of zziplib isn't mine, I only had to compile it once
> because it was necessary for compile other program (TeX Live).
> 
> I'm not talking about POSIX, and I don't mind what it said. I'm
> talking about the man page of dash, that said:
> 

> when \\ is reached is replaced by \.

When \\ is reached AS THE ARGUMENT to echo.

> Then, in the command
>   echo \\\\
> because \\ is reached first, then it will be replaced by '\'

No, you are demonstrating a gap in your understanding of shell quoting
rules.

echo \\\\
echo "\\\\"
echo '\\'
echo '\'"\\"

are all the same way to pass the two-character argument to echo.  That
two-character argument is a valid escape sequence, which in turn means
echo outputs a single \ character then a newline.

> character, immediately after that another \\ is reached, then it will
> be replaced by another '\' character. It turns out the ouput '\\'.

If you want two \ as output, you have to pass four characters (not two)
to echo, so your input has to be one of these (or other) valid quotings:

echo '\\\\'
echo "\\\\\\\\"
echo \\'\'"\\"\\'\'"\\"\\'\'
etc.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2017-07-27 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27 12:23 Bosco
2017-07-27 12:54 ` Eric Blake
2017-07-27 13:13   ` Bosco
2017-07-27 14:24     ` Eric Blake
2017-07-27 14:44       ` Bosco
2017-07-27 14:51         ` Eric Blake
2017-07-27 15:10           ` Bosco
2017-07-27 15:19             ` Eric Blake [this message]
2017-07-27 15:32             ` Bosco
2017-07-27 17:26       ` Harald van Dijk

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=bdcef3ab-073b-370b-011d-fc918210b568@redhat.com \
    --to=eblake@redhat.com \
    --cc=dash@vger.kernel.org \
    --cc=jbosco.gg@gmail.com \
    --subject='Re: echo "\\1"?' \
    /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

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