Skip to content

Commit ea425c9

Browse files
author
Jean-Louis Fuchs
committed
Fix _pipepager() to work with multi-call binaries
Programs such as BusyBox, Toybox and Coreutils (also gzib, bzip etc) in multi-call mode derive their identity from the symlink. Resolving the symlink causes them to misbehave.
1 parent 309ce91 commit ea425c9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

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)