From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10250 invoked from network); 24 Mar 2005 02:08:04 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 24 Mar 2005 02:08:04 -0000 Received: (qmail 96405 invoked from network); 24 Mar 2005 02:07:58 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 24 Mar 2005 02:07:58 -0000 Received: (qmail 5460 invoked by alias); 24 Mar 2005 02:07:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21061 Received: (qmail 5446 invoked from network); 24 Mar 2005 02:07:54 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 24 Mar 2005 02:07:54 -0000 Received: (qmail 96122 invoked from network); 24 Mar 2005 02:07:54 -0000 Received: from 209-128-98-052.bayarea.net (HELO Yost.com) (209.128.98.52) by a.mx.sunsite.dk with SMTP; 24 Mar 2005 02:07:49 -0000 Received: from [192.168.1.2] (209-128-98-052.bayarea.net [209.128.98.52]) by Yost.com (Postfix) with ESMTP id F35773B9E29 for ; Wed, 23 Mar 2005 18:07:46 -0800 (PST) Mime-Version: 1.0 Message-Id: In-Reply-To: <87fyylbzte.fsf@ceramic.fifi.org> References: <87fyylbzte.fsf@ceramic.fifi.org> Date: Wed, 23 Mar 2005 18:03:27 -0800 To: zsh-workers@sunsite.dk From: Dave Yost Subject: Re: there should be a way to echo with quotes or escaping Content-Type: text/plain; charset="us-ascii" X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.3 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.3 At 5:25 PM -0800 2005-03-23, Philippe Troin wrote: >Dave Yost writes: > >> Z% echo "abc def" >> abc def >> Z% echoquoted "abc def" >> 'abc def' >> Z% echoescaped "abc def" >> abc\ def >> Z% >> >> or some such >> > > If there is such a feature, I didn't see it mentioned under the echo >> command in the man page. > >% a="foo' bar" >% echo ${(q)a} >foo\'\ bar >% echo ${(qq)a} >'foo'' bar' >% echo ${(qqq)a} >"foo' bar" > >Note that I have rc_quotes set, otherwise: > >% echo ${(qq)a} >'foo'\'' bar' > >Phil. This should be documented. If it's in the man pages somewhere, it's not in a form that one can grep for. These searches in zshall come up with nothing: \${\(q qqq rc_quotes and there should be some mention under the echo command. Furthermore, none of these three choices is best. Forgetting the rc_quotes option, which is for aliens, they all resort to backslash for shell metacharacters like $ ` etc. 229 Z% x="a 'b' "'$a `date` "c"' 233 Z% setopt rc_quotes ; echo ${(q)x} ; echo ${(qq)x} ; echo ${(qqq)x} a\ \'b\'\ \$a\ \`date\`\ \"c\" 'a ''b'' $a `date` "c"' "a 'b' \$a \`date\` \"c\"" 234 Z% unsetopt rc_quotes ; echo ${(q)x} ; echo ${(qq)x} ; echo ${(qqq)x} a\ \'b\'\ \$a\ \`date\`\ \"c\" 'a '\''b'\'' $a `date` "c"' "a 'b' \$a \`date\` \"c\"" Perhaps there should be an option (qqqq)? that does something more like what a human would do, like this: "a 'b' "'$a `date` "c"' Thanks Dave