diff --git a/docs/parsers/history.md b/docs/parsers/history.md index 2151e0ff..636862a0 100644 --- a/docs/parsers/history.md +++ b/docs/parsers/history.md @@ -87,4 +87,4 @@ Returns: ### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd -Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) +Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/jc/parsers/history.py b/jc/parsers/history.py index adcc7aa9..095f09c1 100644 --- a/jc/parsers/history.py +++ b/jc/parsers/history.py @@ -63,7 +63,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.6' + version = '1.7' description = '`history` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -117,17 +117,14 @@ def parse(data, raw=False, quiet=False): raw_output = {} if jc.utils.has_data(data): + linedata = data.splitlines() - # split lines and clear out any non-ascii chars - linedata = data.encode('ascii', errors='ignore').decode().splitlines() - - # Skip any blank lines for entry in filter(None, linedata): try: - parsed_line = entry.split(maxsplit=1) - raw_output[parsed_line[0]] = parsed_line[1] - except IndexError: - # need to catch indexerror in case there is weird input from prior commands + number, command = entry.split(maxsplit=1) + raw_output[number] = command + except ValueError: + # need to catch ValueError in case there is weird input from prior commands pass if raw: