[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RFE: a way to echo the arguments with quoting
From: |
Dave Yost |
Subject: |
RFE: a way to echo the arguments with quoting |
Date: |
Sat, 1 Mar 2014 14:34:56 -0800 |
I have an ugly function I wrote for zsh that does this:
Sat 14:17:25 ip2 yost /Users/yost
1 634 Z% echo-quoted xyz \$foo 'a b c ' '\n'
xyz '$foo' 'a b c ' '\n'
Sat 14:17:53 ip2 yost /Users/yost
0 635 Z%
It would be nice if there were an easy way to do this in bash.
Here is my use case:
echo-command() {
echo -n 1>&2 "[ "
echo-quoted -n 1>&2 $@
echo 1>&2 " ]"
}
echodo() {
echo-command $@
eval "$@"
}
1 652 Z% echodo sleep 1
[ sleep 1 ]
0 653 Z%
This is a bit of a hack because when I need to use a pipe character, for
example, I have to quote it, and that gets echoed in a way that’s wrong for
this purpose.
0 656 Z% echodo echo abc \| sed 's,b,_,'
[ echo abc '|' sed s,b,_, ]
a_c
0 657 Z%
A builtin that does my ‘echodo’ without having to escape command-line
metacharacters is what I really want.
Is there such a thing?
- RFE: a way to echo the arguments with quoting,
Dave Yost <=