Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty PAGER variable breaks help subcommands #8891

Closed
graywolf-s1 opened this issue Sep 2, 2024 · 3 comments
Closed

Empty PAGER variable breaks help subcommands #8891

graywolf-s1 opened this issue Sep 2, 2024 · 3 comments
Assignees
Labels
bug This issue is a bug. duplicate This issue is a duplicate.

Comments

@graywolf-s1
Copy link

Describe the bug

When PAGER is set to empty string, help stops working.

Expected Behavior

The help would continue to work, behaving as if pager was disabled. Setting PAGER to empty string is fairly common way to disable pager usage, and works with all programs I use except awscli.

Current Behavior

list index out of range

Reproduction Steps

$ PAGER= aws s3 help

list index out of range

Possible Solution

Probably changing

if not self._exists_on_path(cmdline[0]):

to

if not (cmdline and self._exists_on_path(cmdline[0])):

should work. Assuming that is valid python, I am not pythonist.

Additional Information/Context

No response

CLI version used

aws-cli/2.17.27 Python/3.11.9 Darwin/23.6.0 source/arm64

Environment details (OS name and version, etc.)

MacOS Sodoma 14.6.1

@graywolf-s1 graywolf-s1 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 2, 2024
@graywolf-s1
Copy link
Author

diff --git a/awscli/help.py b/awscli/help.py
index 14b91c7ed..3a14c882b 100644
--- a/awscli/help.py
+++ b/awscli/help.py
@@ -136,10 +136,10 @@ class PosixHelpRenderer(PagingHelpRenderer):
 
     def _send_output_to_pager(self, output):
         cmdline = self.get_pager_cmdline()
-        if not self._exists_on_path(cmdline[0]):
+        if not (cmdline and self._exists_on_path(cmdline[0])):
             LOG.debug(
-                "Pager '%s' not found in PATH, printing raw help.", cmdline[0]
-            )
+                "Pager '%s' not found in PATH, printing raw help.",
+                cmdline[0] if cmdline else "<empty>")
             self.output_stream.write(output.decode('utf-8') + "\n")
             self.output_stream.flush()
             return

^ Seems to suffice as a fix.

@tim-finnigan tim-finnigan self-assigned this Sep 3, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. This looks like a duplicate of #4972, so I'll close this and we can continue tracking there. This comment on the issue provides more background and a workaround (for when AWS_PAGER is set to an empty string):

In the pull request, it was intended that the pagers only affected command output. That being said, I'm not opposed to adding the option to control the pager functionality for the help command as well. The only thing thing I'm hesitant about is making the help pager rely on the same variables as the output pager (e.g. AWS_PAGER) as it may result in unexpected behavior for users that upgrade and not expecting the AWS_PAGER variable to affect their help output. I think if we add it, it would likely be through another environment and config variables (e.g. AWS_HELP_PAGER). This option would also give more granularity over how to page different types of outputs as well

In the meantime if you want to have the help output be printed directly to stdout, you can use a pipe (i.e. to something like cat) and the CLI will not send it to the pager.

$ aws ec2 help | cat

Please refer to the original issue for updates going forward or to add any comments.

@tim-finnigan tim-finnigan closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2024
@tim-finnigan tim-finnigan added duplicate This issue is a duplicate. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 3, 2024
Copy link

github-actions bot commented Sep 3, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. duplicate This issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

2 participants