Skip to content

Commit db23e4c

Browse files
committed
uname: Fix long options support
1 parent f6fa640 commit db23e4c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

userland/utilities/uname.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44

55
from .. import core
66

7-
UNAME_ATTRS = frozenset("mnrsv")
7+
# mapping of uname_result attribute name to option atttribute name
8+
UNAME_ATTRS = {
9+
"sysname": "kernel_name",
10+
"nodename": "nodename",
11+
"release": "kernel_release",
12+
"version": "kernel_version",
13+
"machine": "machine",
14+
}
815

916

1017
parser = core.create_parser(
@@ -75,21 +82,23 @@ def python_userland_uname(opts, args):
7582

7683
extras: list[str] = []
7784

78-
if opts.a:
79-
for attr in UNAME_ATTRS:
80-
setattr(opts, attr, True)
85+
if opts.all:
86+
for optname in UNAME_ATTRS.values():
87+
setattr(opts, optname, True)
8188
else:
82-
if opts.p:
89+
if opts.processor:
8390
extras.append("unknown")
8491

85-
if opts.i:
92+
if opts.hardware_platform:
8693
extras.append("unknown")
8794

88-
if opts.o:
95+
if opts.operating_system:
8996
extras.append("unknown")
9097

91-
if not extras and not any({getattr(opts, attr) for attr in UNAME_ATTRS}):
92-
opts.s = True
98+
if not extras and not any(
99+
{getattr(opts, optname) for optname in UNAME_ATTRS.values()}
100+
):
101+
opts.kernel_name = True
93102

94103
uname = os.uname()
95104

@@ -104,7 +113,7 @@ def python_userland_uname(opts, args):
104113
"version",
105114
"machine",
106115
]
107-
if getattr(opts, attribute[0])
116+
if getattr(opts, UNAME_ATTRS[attribute])
108117
]
109118
+ extras
110119
)

0 commit comments

Comments
 (0)