Skip to content

Commit 36ee72c

Browse files
dcermakphilpep
authored andcommitted
Use realpath by default to resolve symlinks instead of readlink -f
Older versions of busybox do not support the -f flag for readlink. realpath on the other hand works both for the GNU coreutils & busybox. To be safe, we still fall back to readlink -f in case realpath is not available on the system.
1 parent 4614915 commit 36ee72c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

testinfra/modules/file.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def linked_to(self):
6161
>>> host.file("/var/lock").linked_to
6262
'/run/lock'
6363
"""
64+
res = self.run_expect([0, 127], "realpath %s", self.path)
65+
if res.rc == 0:
66+
return res.stdout.strip()
6467
return self.check_output("readlink -f %s", self.path)
6568

6669
@property

0 commit comments

Comments
 (0)