Skip to content

Commit 486d01c

Browse files
rohiebEmantor
authored andcommitted
linux: search for commands in /bin, /sbin too
Be compatible with distros that don't implement usr merge. If /bin and /sbin are symlinks to /usr/[s]bin, this could list the same directory contents again, so refactor the commands variable into a set instead of an array. Signed-off-by: Roland Hieber <[email protected]>
1 parent 27ebbe4 commit 486d01c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

labgridhelper/linux.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,18 @@ def get_commands(command, directories=None):
112112
"""
113113
assert isinstance(command, CommandProtocol), "command must be a CommandProtocol"
114114
out = command.run_check("ls /usr/bin")
115+
out.extend(command.run_check("ls /bin"))
115116
out.extend(command.run_check("ls /usr/sbin"))
117+
out.extend(command.run_check("ls /sbin"))
116118
if directories:
117119
assert isinstance(directories, list), "directories must be a list"
118120
for directory in directories:
119121
out.extend(command.run_check("ls {}".format(directory)))
120-
commands = []
122+
commands = set()
121123
for line in out:
122124
for cmd in line.split(" "):
123125
if cmd:
124-
commands.append(cmd)
126+
commands.add(cmd)
125127

126128
return commands
127129

0 commit comments

Comments
 (0)