One can see the full extent of the brokenness of the command (in all
versions I've seen) using

#!/usr/bin/env python3

from itertools import combinations, chain, repeat
from subprocess import check_output as sco
import json

cmd = ['lshw', '-json', '-quiet']

classes = 'system bus memory processor bridge display generic multimedia
storage network'.split()

if __name__ == '__main__':
    for flags in chain(*(combinations(classes, n) for n in 
range(len(classes)))):
        flags = chain(*zip(repeat('-c'), flags))
        flags = list(flags)
        if True:
            try:
                json.loads(sco(cmd + flags))
                print(" ".join(flags), "was OK")
            except json.decoder.JSONDecodeError as e:
                print(' '.join(flags))
                print(e)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1405873

Title:
  -json output not valid when -class filter used

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lshw/+bug/1405873/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to