Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Quoting in zsh -x output
- X-seq: zsh-workers 17490
- From: Hrvoje Niksic <hniksic@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Quoting in zsh -x output
- Date: Tue, 30 Jul 2002 18:26:59 +0200
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: hniksic@xxxxxxxxxxxxxxxxxxxxxxxxx
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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author