Prevent endless recursive pager
Unset PAGER environment variable when executing the command referenced in PAGER in case that command also has support for PAGER and would end up executing itself indefinitely.
This commit is contained in:
parent
6ad6784c46
commit
76181156ba
1 changed files with 5 additions and 0 deletions
|
|
@ -103,6 +103,11 @@ func (s *IOStreams) StartPager() error {
|
|||
}
|
||||
|
||||
pagerEnv := os.Environ()
|
||||
for i := len(pagerEnv) - 1; i >= 0; i-- {
|
||||
if strings.HasPrefix(pagerEnv[i], "PAGER=") {
|
||||
pagerEnv = append(pagerEnv[0:i], pagerEnv[i+1:]...)
|
||||
}
|
||||
}
|
||||
if _, ok := os.LookupEnv("LESS"); !ok {
|
||||
pagerEnv = append(pagerEnv, "LESS=FRX")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue