Skip to content

Commit 5f86603

Browse files
authored
Fix _pipepager()/_tempfilepage() to work with multi-call binaries (#2944)
2 parents 413f76f + 34723d1 commit 5f86603

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/click/_termui_impl.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,11 @@ def _pipepager(
429429
cmd_filepath = shutil.which(cmd)
430430
if not cmd_filepath:
431431
return False
432-
# Resolves symlinks and produces a normalized absolute path string.
433-
cmd_path = Path(cmd_filepath).resolve()
432+
433+
# Produces a normalized absolute path string.
434+
# multi-call binaries such as busybox derive their identity from the symlink
435+
# less -> busybox. resolve() causes them to misbehave. (eg. less becomes busybox)
436+
cmd_path = Path(cmd_filepath).absolute()
434437
cmd_name = cmd_path.name
435438

436439
import subprocess
@@ -520,8 +523,10 @@ def _tempfilepager(
520523
cmd_filepath = shutil.which(cmd)
521524
if not cmd_filepath:
522525
return False
523-
# Resolves symlinks and produces a normalized absolute path string.
524-
cmd_path = Path(cmd_filepath).resolve()
526+
# Produces a normalized absolute path string.
527+
# multi-call binaries such as busybox derive their identity from the symlink
528+
# less -> busybox. resolve() causes them to misbehave. (eg. less becomes busybox)
529+
cmd_path = Path(cmd_filepath).absolute()
525530

526531
import subprocess
527532
import tempfile

0 commit comments

Comments
 (0)