Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/System.Management.Automation/engine/InitialSessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5475,10 +5475,18 @@ internal static SessionStateAliasEntry[] BuiltInAliases
internal const string DefaultMoreFunctionText = @"
param([string[]]$paths)
$OutputEncoding = [System.Console]::OutputEncoding
$moreCommand = (Get-Command -CommandType Application more).Definition | Select-Object -First 1

# Respect PAGER, use more on Windows, and use less on Linux
if (Test-Path env:PAGER) {
$moreCommand = (Get-Command -CommandType Application $env:PAGER).Definition | Select-Object -First 1
} elseif ($IsWindows) {
$moreCommand = (Get-Command -CommandType Application more).Definition | Select-Object -First 1
} else {
$moreCommand = (Get-Command -CommandType Application less).Definition | Select-Object -First 1
}

if($paths) {
foreach ($file in $paths)
{
foreach ($file in $paths) {
Get-Content $file | & $moreCommand
}
} else { $input | & $moreCommand }
Expand Down