Open jimbo8098 opened 7 months ago
Hi @jimbo8098, thanks for reaching out. I'm still investigating this issue, but I wanted bring up that I think cli_pager =
is actually working correctly. Your reproduction steps are setting both though, and from the environment variables docs, AWS_PAGER
overrides cli_pager =
.
I've been able to reproduce the issue with AWS_PAGER
and am trying to root cause the problem.
My default Powershell profile .ps1
nor the default environment variables include a definition for AWS_PAGER
. Here are the commands run in a newly opened Powershell window:
> echo "`"$Env:AWS_PAGER`""
""
> $Env:AWS_PAGER=""
> echo "`"$Env:AWS_PAGER`""
""
> $Env:AWS_PAGER="less"
> echo "`"$Env:AWS_PAGER`""
"less"
When cli_pager
is not present in the AWS profile alongside $Env:AWS_PAGER
set to ""
, paginated output is shown.
I suspect the environment variable is being interpreted incorrectly. Perhaps some oversight in how scopes in Windows might be different and the aspect of comparitors in Powershell specifically being a bit more advanced than a usual if[]
block in Bash.
You have $Env:AWS_PAGER
, sure, but you also have local scope with AWS_PAGER
and also the machine level scope commonly set through setx
or the environment variable dialog. Commonly, I'd expect that setting $Env:AWS_PAGER
is most useful for a setting you wish to have persist temporarily for a Powershell terminal session, which is what I'd expect of this kind of definition. The cli_pager
on the other hand would be a more persistent setting, remaining beyond just that session.
The presence of cli_pager=
in the config file for the given profile works as expected. I was previously setting the default
profile to use cli_pager=
but this wasn't affecting the pagination but this is fine when set at a named profile scope. I had misread the documentation assuming this to set the default value for this which was incorrect.
Describe the bug
The
AWS_PAGER
environment variable orcli_pager
config file parameter is not obeyed specifically if you wish to disable pagination. It is obeyed if you set it to a paginator of your choice.Expected Behavior
Per the AWS CLI documentation you can set the
AWS_PAGER
environment variable to be a blank string (i.e. not $null) or you can set the relevant option in config like so:Both of these would not result in paginated output.
Current Behavior
Note that if I instead run the AWS CLI command with
--no-cli-pager
, like below, the command works as expected:Reproduction Steps
~/.aws/config
'sdefault
profile to havecli_pager=
[System.Environment]::SetEnvironmentVariable("AWS_PAGER","")
$Env:AWS_PROFILE
to the relevant profile name.describe-instances
command above. The output is be paginated.Possible Solution
I use both Windows and Linux and haven't seen this same behaviour exhibited by Linux. I therefore suspect that this is just an oversight in how Windows handles variables.
Additional Information/Context
aws-cli/2.13.25 Python/3.11.5 Windows/10 exe/AMD64 prompt/off
CLI version used
aws-cli/2.13.25 Python/3.11.5 Windows/10 exe/AMD64 prompt/off
Environment details (OS name and version, etc.)
Windows 10 Business 10.0.19045