mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
udevadm: automatically anable JSON-SEQ in case JSON is used for "udevadm info -a"
We are going to output a series of JSON objects, hence let's
automatically enable JSON-SEQ output mode, as we usually do.
"jq --seq" supports this natively, hence this should not really restrict
us.
Follow-up for: 67ea8a4c0e
This commit is contained in:
parent
7aea1c9e80
commit
ebc64de22f
@ -167,6 +167,11 @@
|
|||||||
<para>Print all sysfs properties of the specified device that can be used
|
<para>Print all sysfs properties of the specified device that can be used
|
||||||
in udev rules to match the specified device. It prints all devices
|
in udev rules to match the specified device. It prints all devices
|
||||||
along the chain, up to the root of sysfs that can be used in udev rules.</para>
|
along the chain, up to the root of sysfs that can be used in udev rules.</para>
|
||||||
|
|
||||||
|
<para>This switch supports JSON output mode (see <option>--json=</option> below). Note that
|
||||||
|
because this switch generates multiple JSON objects, JSON-SEQ mode is automatically enabled
|
||||||
|
(RFC7464). (Note: tools such as <ulink url="https://jqlang.github.io/jq/manual/">jq</ulink>
|
||||||
|
natively support JSON-SEQ via the <option>--seq</option> switch.)</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -274,6 +274,8 @@ static int print_device_chain_in_json(sd_device *device) {
|
|||||||
|
|
||||||
assert(device);
|
assert(device);
|
||||||
|
|
||||||
|
arg_json_format_flags |=SD_JSON_FORMAT_SEQ;
|
||||||
|
|
||||||
r = print_all_attributes_in_json(device, /* is_parent = */ false);
|
r = print_all_attributes_in_json(device, /* is_parent = */ false);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -71,8 +71,8 @@ udevadm info --query symlink --root /sys/class/net/$netdev
|
|||||||
(! udevadm info -q hello -r /sys/class/net/$netdev)
|
(! udevadm info -q hello -r /sys/class/net/$netdev)
|
||||||
udevadm info -a /sys/class/net/$netdev
|
udevadm info -a /sys/class/net/$netdev
|
||||||
udevadm info -a --json=off /sys/class/net/$netdev
|
udevadm info -a --json=off /sys/class/net/$netdev
|
||||||
udevadm info -a --json=pretty /sys/class/net/$netdev | jq . >/dev/null
|
udevadm info -a --json=pretty /sys/class/net/$netdev | jq --seq . >/dev/null
|
||||||
udevadm info -a --json=short /sys/class/net/$netdev | jq . >/dev/null
|
udevadm info -a --json=short /sys/class/net/$netdev | jq --seq . >/dev/null
|
||||||
udevadm info -t >/dev/null
|
udevadm info -t >/dev/null
|
||||||
udevadm info --tree /sys/class/net/$netdev
|
udevadm info --tree /sys/class/net/$netdev
|
||||||
udevadm info -x /sys/class/net/$netdev
|
udevadm info -x /sys/class/net/$netdev
|
||||||
|
Loading…
Reference in New Issue
Block a user