diff --git a/awscli/shorthand.py b/awscli/shorthand.py index 374b12d08f03..c95b7139d7ac 100644 --- a/awscli/shorthand.py +++ b/awscli/shorthand.py @@ -64,7 +64,7 @@ def __init__(self, value, expected, actual, index): super(ShorthandParseError, self).__init__(msg) def _construct_msg(self): - if '\n' in self.value: + if '\n' in self.value[:self.index]: # If there's newlines in the expression, we want # to make sure we're only counting the spaces # from the last newline: @@ -79,8 +79,10 @@ def _construct_msg(self): "Expected: '%s', received: '%s' for input:\n" "%s\n" "%s\n" - ) % (self.expected, self.actual, self.value, - ' ' * num_spaces + '^') + "%s\n" + ) % (self.expected, self.actual, self.value[:self.index], + ' ' * num_spaces + '^', + self.value[self.index:]) return msg diff --git a/tests/unit/test_shorthand.py b/tests/unit/test_shorthand.py index 72437eb9dc62..bd80d65d2613 100644 --- a/tests/unit/test_shorthand.py +++ b/tests/unit/test_shorthand.py @@ -160,7 +160,7 @@ def test_error_parsing(): yield (_is_error, "foo={bar}") yield (_is_error, "foo={bar=bar") yield (_is_error, "foo=bar,") - + yield (_is_error, "foo=bar',\nbar=bar") def _is_error(expr): try: