zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: there should be a way to echo with quotes or escaping
Date: Thu, 24 Mar 2005 01:34:32 +0000	[thread overview]
Message-ID: <1050324013432.ZM15894@candle.brasslantern.com> (raw)
In-Reply-To: <pdy988306210204be6796f21c1b@[192.168.1.2]>

On Mar 23,  2:00pm, Dave Yost wrote:
} 
} If there is such a feature, I didn't see it mentioned under the echo 
} command in the man page.

The way to do this is with parameter expansion:

Z% raw="abc def"
Z% echo ${(q)raw}
abc\ def
Z% echo ${(qq)raw}
'abc def'
Z% echo ${(qqq)raw}
"abc def"
Z% echo ${(qqqq)raw}
$'abc def'

(More than four "q"s doesn't change anything after that.)

To skip the assignment to "raw", just:

Z% echo ${(q):-"abc def"}
abc\ def

Of course you're really better off using "print -R" than "echo", because
"echo" may re-interpret backslashes etc. embedded in its arguments.


      parent reply	other threads:[~2005-03-24  1:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-23 22:00 Dave Yost
2005-03-24  1:25 ` Philippe Troin
2005-03-24  2:03   ` Dave Yost
2005-03-24  2:55     ` Bart Schaefer
2005-03-24  1:34 ` 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=1050324013432.ZM15894@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).