---
tools/virsh.c | 25 +++++--------------------
1 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index bcf0603..fe1a224 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -12340,27 +12340,12 @@ cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd)
arg = opt->data;
if (count)
virBufferAddChar(&buf, ' ');
- /* Add outer '' only if arg included shell metacharacters. */
- if (shell &&
- (strpbrk(arg, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")
|| !*arg)) {
- virBufferAddChar(&buf, '\'');
- close_quote = true;
- }
- if (xml) {
+ if (xml)
virBufferEscapeString(&buf, "%s", arg);
- } else {
- if (shell && (q = strchr(arg, '\''))) {
- do {
- virBufferAdd(&buf, arg, q - arg);
- virBufferAddLit(&buf, "'\\''");
- arg = q + 1;
- q = strchr(arg, '\'');
- } while (q);
- }
- virBufferAdd(&buf, arg, strlen(arg));
- }
- if (close_quote)
- virBufferAddChar(&buf, '\'');
+ else if (shell)
+ virBufferEscapeShell(&buf, arg);
+ else
+ virBufferAdd(&buf, arg, -1);
count++;
}
--
1.7.6.3