summaryrefslogtreecommitdiff
path: root/cliff/formatters/shell.py
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2014-04-03 13:00:08 -0400
committerRyan Petrello <lists@ryanpetrello.com>2014-04-03 18:00:22 -0400
commite9973ad72861ffbbacb0d4471ea7afc80ce31fe8 (patch)
tree6db1b09895e57fd45d6a1c49a5f57e99dbbb40fa /cliff/formatters/shell.py
parenta52c09fa34da16aea1a235f66267d07ac0ae4ed6 (diff)
downloadcliff-e9973ad72861ffbbacb0d4471ea7afc80ce31fe8.tar.gz
Fix a bug in ShellFormatter's escaping of double quotes in strings.
Fixes bug: 1302066 Change-Id: I7fe066165ce11cfe977a18c0e49a55ff84ba4187
Diffstat (limited to 'cliff/formatters/shell.py')
-rw-r--r--cliff/formatters/shell.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/cliff/formatters/shell.py b/cliff/formatters/shell.py
index 385d48c..fd4f29e 100644
--- a/cliff/formatters/shell.py
+++ b/cliff/formatters/shell.py
@@ -3,6 +3,8 @@
from .base import SingleFormatter
+import six
+
class ShellFormatter(SingleFormatter):
@@ -34,6 +36,7 @@ class ShellFormatter(SingleFormatter):
desired_columns = parsed_args.variables
for name, value in zip(variable_names, data):
if name in desired_columns or not desired_columns:
- stdout.write('%s%s="%s"\n' % (parsed_args.prefix, name,
- value.replace('"', '\\"')))
+ if isinstance(value, six.string_types):
+ value = value.replace('"', '\\"')
+ stdout.write('%s%s="%s"\n' % (parsed_args.prefix, name, value))
return