zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Clint Adams <clint@zsh.org>, zsh-workers@sunsite.dk
Subject: Re: [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\]
Date: Sun, 27 Jan 2002 21:32:09 +0000	[thread overview]
Message-ID: <1020127213209.ZM9378@candle.brasslantern.com> (raw)
In-Reply-To: <20020127202405.GB32151@dman.com>

On Jan 27,  3:24pm, Clint Adams wrote:
} Subject: [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read
}
} ----- Forwarded message from Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de> -----
} 
} ~% echo "\\"                       
} \
} ~% echo "\\" | read -r i; echo "$i"
} \
} ~% echo "\\\\\\\\"                       
} \\
} ~% echo "\\\\\\\\" | read -r i; echo "$i"
} \
} 
} The manpage says read -r does not remove \.

`read -r' didn't remove the backslash.  `echo "$i"' removed it, as was
pointed out a moment later:

} Also echo removes \:
} 
} ~% echo "\\\\"                     
} \
} 
} bash will print \\ as intendet. Any reason? (ksh/pdksh print \ I was
} told).

zsh/ksh use the SysV definition of `echo' by default; bash uses the BSD
definition, it would appear.  If one had RTM, one would have found that
`echo -E' does what you meant -- or else you can set the BSD_ECHO option
to get that behavior all the time.

So let's try the first example again with BSD_ECHO set:

schaefer[508] setopt BSD_ECHO
schaefer[509] echo "\\"
\

In this case it was double-quoted expansion that removed the backslash.
Using single quotes shows that it was not echo that removed it:

schaefer[513] echo '\\'
\\

Now back to the example:

schaefer[510] echo "\\" | read -r i; echo "$i"
\
schaefer[511] echo "\\\\\\\\"
\\\\
schaefer[512] echo "\\\\\\\\" | read -r i; echo "$i"
\\\\

Neither read nor echo has removed any backslashes.  Only double-quoting
did so.  Again trying the same thing with single quotes:

schaefer[514] echo '\\\\\\\\' | read -r i; echo "$i"
\\\\\\\\

This is all working exactly as documented.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


      reply	other threads:[~2002-01-27 21:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-27 20:24 Clint Adams
2002-01-27 21:32 ` Bart Schaefer [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=1020127213209.ZM9378@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=clint@zsh.org \
    --cc=zsh-workers@sunsite.dk \
    /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).