Skip to content

Commit 72a8316

Browse files
committed
gh-161039: fix detection of less >= 706 in _pyrepl/pager.py
Since less tag v706¹, less exits with a failure status when no filename is provided. Pass the `-?` option and redirect both stdout and stderr to /dev/null. Failure to detect `less` results in using `more` for users who don't have MANPAGER or PAGER set, which is unexpected. ¹ gwsw/less@7c85230 (Exit with a failure status in more cases, 2026-06-14)
1 parent e80962a commit 72a8316

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎Lib/_pyrepl/pager.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_pager() -> Pager:
3636
return lambda text, title='': tempfile_pager(plain(text), 'more <')
3737
if hasattr(os, 'system') and os.system('(pager) 2>/dev/null') == 0:
3838
return lambda text, title='': pipe_pager(text, 'pager', title)
39-
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
39+
if hasattr(os, 'system') and os.system('(less -?) >/dev/null 2>&1') == 0:
4040
return lambda text, title='': pipe_pager(text, 'less', title)
4141

4242
import tempfile

0 commit comments

Comments
 (0)