zsh-workers
 help / color / mirror / code / Atom feed
From: Hrvoje Niksic <hniksic@xemacs.org>
To: zsh-workers@sunsite.dk
Subject: Quoting in zsh -x output
Date: Tue, 30 Jul 2002 18:26:59 +0200	[thread overview]
Message-ID: <sxsznw96v1o.fsf@florida.munich.redhat.com> (raw)

Bash has a nice feature of its `-x' output: the arguments that contain
whitespace or shell metacharacters are quoted, which allows one to
copy the output and paste it into another shell.  I find this very
useful.

Here is an example:

bash$ set -x
bash$ echo "foo bar"
+ echo 'foo bar'
foo bar
bash$ echo "foo*"
+ echo 'foo*'
foo*
bash$ echo "foo'bar"
+ echo 'foo'\''bar'
foo'bar
bash$ echo "foo"
+ echo foo
foo

The last example shows that the quotes are printed only when needed.
Arguments containing whitespace and metacharacters are quoted, and
embedded single quotes are handled correctly.  This makes sure that
pasting the output produces the same results.

Zsh, on the other hand, prints this:

zsh$ set -x
zsh$ echo "foo bar"
+zsh:2> echo foo bar
foo bar
zsh$ echo "foo*"
+zsh:3> echo foo*
foo*
zsh$ echo "foo'bar"
+zsh:4> echo foo'bar
foo'bar
zsh$ echo "foo"
+zsh:5> echo foo
foo

I suggest modifying the zsh `-x' output to quote its arguments the way
Bash does.  What do the others think?


             reply	other threads:[~2002-07-30 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-30 16:26 Hrvoje Niksic [this message]
2002-07-30 17:03 ` Peter Stephenson
2002-07-30 20:50   ` Dan Nelson
2002-07-31  9:42     ` Peter Stephenson
2002-07-31 14:55       ` Bart Schaefer
2002-08-03 17:05 Hrvoje Niksic

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=sxsznw96v1o.fsf@florida.munich.redhat.com \
    --to=hniksic@xemacs.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).