From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17568 invoked from network); 7 Feb 2002 20:22:47 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 7 Feb 2002 20:22:47 -0000 Received: (qmail 20566 invoked by alias); 7 Feb 2002 20:22:38 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16588 Received: (qmail 20540 invoked from network); 7 Feb 2002 20:22:29 -0000 Date: Thu, 7 Feb 2002 12:22:22 -0800 From: Derek Peschel To: zsh-workers@sunsite.dk Subject: Re: BUG? - 4.0.2 - parameter substitution won't double backslashes in values Message-ID: <20020207122222.A14893@eskimo.eskimo.com> References: <20020207051955.A26840@eskimo.eskimo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from schaefer@brasslantern.com on Thu, Feb 07, 2002 at 07:20:38PM +0000 On Thu, Feb 07, 2002 at 07:20:38PM +0000, Bart Schaefer wrote: > On Thu, 7 Feb 2002, Derek Peschel wrote: > > But I would still expect some change (a backspace should change to "\b" when > > using "print", or "\b" should change to "\\b" when using "print -r"). > > Um, no. With "print" a "\b" changes to backspace; with "print -r", "\b" > remains "\b". In either case a literal backspace remains a backspace. > > If you want to convert backspace and other "control characters" to a > visible representation, you can use the (V) parameter flag: > > zsh% bs=$(print -n '\b') > zsh% print ${(V)bs} > ^H > > Note that the conversion from '\b' to backspace was done by print, and the > conversion from backspace to ^H was done by parameter expansion. There is > no built-in mechanism to convert from backspace to '\b'. Maybe my explanation was too complicated, or probably you missed the beginning of the thread. I have a string containing the characters "a", backslash, "b", "c". When I print it using "print", it appears as "ac" (because the backslash, "b" gets converted to backspace). When I print it using "print -r", it appears as "a\bc". I want to use parameter substitution to convert the backslash to two backslashes. I haven't managed it yet -- that's what I was referring to when I wrote "but I would still expect some change". Assuming I did manage it, I would have the five characters "a", backslash, backslash, "b", "c". If I printed _them_ using "print", I would expect to see "a\bc" and if I printed them using "print -r" I would expect to see "a\\bc". My first post has all the examples in it. Please see that one. -- Derek