You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Passing parameters to $env:PAGER is broken in 6.2.0-preview.4 #8912
I have $env:PAGER set to less "-PPowerShell help page line %lt (press h for help or q to quit)" and on PS Core 6.1.0 on Windows 10 1809, PS Core uses less and gives me this nice footer during paging:
But in PS Core 6.2.0-preview.4 that same env var setting, causes more.com to be invoked. That is rather rude - ignoring my less preference.
Steps to reproduce
Set the following env var value.
$env:PAGER='less "-PPowerShell help page line %lt (press h for help or q to quit)"'
Expected behavior
I get paging via less and with my desired footer.
Actual behavior
more.com is invoked instead.
Environment data
Name Value
---- -----
PSVersion 6.2.0-preview.4
PSEdition Core
GitCommitId 6.2.0-preview.4
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Ah, I see this warning when I scroll up - it goes by pretty fast and winds up off-screen:
WARNING: Ignoring invalid custom-paging utility command line specified in $env:PAGER: less "-PPowerShell help page line %lt (press h for help or q to quit)"
OK, so this is a (lesser) breaking change. Is there a work-around?
# Split the command line into tokens, respecting quoting.
$customPagerCommand, $customPagerCommandArgs = & { Write-Output -- $customPagerCommandLine }
e.g.
$customPagerCommandLine = 'less "-PPowerShell help page line %lt (press h for help or q to quit)"'
$customPagerCommand, $customPagerCommandArgs = & { Write-Output -- $customPagerCommandLine }
Outputs the entire value to $customPagerCommand because $customPagerCommandLine is always interpreted as a single string. Something like this works but I wouldn't recommend iex:
Keith Hill (@rkeithhill)Rob Holt (@rjmholt)
First of all thanks for your investigative work. :)
I've looked into this issue and it does seem that my code is not tokenizing the custom env:PAGER that is being set. I am about to open a PR that tokenizes properly and once it is merged this env:PAGER variable will work :
$env:PAGER='"C:\Program Files\Git\usr\bin\less.exe" "-PPowerShellhelp page line %lt (press h for help or q to quit)"'
You should replace the path specified with whichever path the less executable is located at. However since you said your PSCore uses less you might not even need the path.
Activity
rkeithhill commentedon Feb 19, 2019
Ah, I see this warning when I scroll up - it goes by pretty fast and winds up off-screen:
OK, so this is a (lesser) breaking change. Is there a work-around?
rkeithhill commentedon Feb 19, 2019
I'm not sure this script works as expected:
e.g.
Outputs the entire value to
$customPagerCommandbecause$customPagerCommandLineis always interpreted as a single string. Something like this works but I wouldn't recommend iex:rkeithhill commentedon Feb 19, 2019
Another possible approach:
rjmholt commentedon Feb 19, 2019
Looks like this is defined here:
PowerShell/src/System.Management.Automation/engine/InitialSessionState.cs
Lines 4106 to 4215 in ff3edaa
Possibly last changed in this commit: 4858afb.
pougetat commentedon Feb 19, 2019
Just saw this issue. I'll look into it asap since I committed that code. :)
pougetat commentedon Feb 19, 2019
Keith Hill (@rkeithhill) Rob Holt (@rjmholt)
First of all thanks for your investigative work. :)
I've looked into this issue and it does seem that my code is not tokenizing the custom env:PAGER that is being set. I am about to open a PR that tokenizes properly and once it is merged this env:PAGER variable will work :
You should replace the path specified with whichever path the less executable is located at. However since you said your PSCore uses less you might not even need the path.
Fix help paging issues on macOS/Linux and with custom pager that take…
Fix help paging issues on macOS/Linux and with custom pager that take…