Skip to content

Handle $PAGER being a command with args#6

Open
kba wants to merge 2 commits into
dominictarr:masterfrom
kba:pager-env-with-args
Open

Handle $PAGER being a command with args#6
kba wants to merge 2 commits into
dominictarr:masterfrom
kba:pager-env-with-args

Conversation

@kba

@kba kba commented Aug 7, 2016

Copy link
Copy Markdown

If $PAGER is set to a command with arguments (e.g. less -Rs),
default-pager tried to execute the whole call as a binary. With this
change, the $PAGER call will be split into command and arguments.

It's still rather naive, won't handle arguments with escaped spaces or
in quotes but it works for single-character arguments such as those used
by less.

If `$PAGER` is set to a command with arguments (e.g. `less -Rs`),
default-pager tried to execute the whole call as a binary. With this
change, the `$PAGER` call will be split into command and arguments.

It's still rather naive, won't handle arguments with escaped spaces or
in quotes but it works for single-character arguments such as those used
by `less`.
Comment thread index.js Outdated
if (pager.indexOf(' ') > 0) {
var pagerAndArgs = pager.split(/\s+/);
pager = pagerAndArgs[0]
opts.args = pagerAndArgs.slice(1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you append opts.args to pager args, not replace them?

@eush77

eush77 commented Aug 8, 2016

Copy link
Copy Markdown
Collaborator

Thank you!

I think it's worth it to keep it that simple for now. If there's ever a need for something more complex, we will add it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants