@@ -1262,7 +1262,8 @@ def pfeedback(self, msg):
12621262 def ppaged (self , msg , end = '\n ' ):
12631263 """Print output using a pager if it would go off screen and stdout isn't currently being redirected.
12641264
1265- Never uses a pager inside of a script (Python or text) or when output is being redirected or piped.
1265+ Never uses a pager inside of a script (Python or text) or when output is being redirected or piped or when
1266+ stdout or stdin are not a fully functional terminal.
12661267
12671268 :param msg: str - message to print to current stdout - anything convertible to a str with '{}'.format() is OK
12681269 :param end: str - string appended after the end of the message if not already present, default a newline
@@ -1273,8 +1274,16 @@ def ppaged(self, msg, end='\n'):
12731274 if not msg_str .endswith (end ):
12741275 msg_str += end
12751276
1277+ # Attempt to detect if we are not running within a fully functional terminal.
1278+ # Don't try to use the pager when being run by a continuous integration system like Jenkins + pexpect.
1279+ functional_terminal = False
1280+ if self .stdin .isatty () and self .stdout .isatty ():
1281+ if sys .platform .startswith ('win' ) or os .environ .get ('TERM' ) is not None :
1282+ functional_terminal = True
1283+
12761284 # Don't attempt to use a pager that can block if redirecting or running a script (either text or Python)
1277- if not self .redirecting and not self ._in_py and not self ._script_dir :
1285+ # Also only attempt to use a pager if actually running in a real fully functional terminal
1286+ if functional_terminal and not self .redirecting and not self ._in_py and not self ._script_dir :
12781287 if sys .platform .startswith ('win' ):
12791288 pager_cmd = 'more'
12801289 else :
0 commit comments