Skip to content

Commit

Permalink
Disable readline if stdin is not attached to a terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed May 17, 2021
1 parent 977b868 commit 3bcd162
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/sysfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -3481,8 +3481,10 @@ void InitSysFiles(void)
setbuf(stderr, (char *)0);

#ifdef HAVE_LIBREADLINE
rl_readline_name = "GAP";
rl_initialize ();
if (SyUseReadline) {
rl_readline_name = "GAP";
rl_initialize();
}
#endif
}

Expand Down
15 changes: 11 additions & 4 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,6 @@ void InitSystem (
}
#endif

InitSysFiles();

if (handleSignals) {
SyInstallAnswerIntr();
}
Expand Down Expand Up @@ -816,11 +814,20 @@ void InitSystem (
}

}
/* adjust SyUseReadline if no readline support available or for XGAP */
#if !defined(HAVE_LIBREADLINE)
// don't use readline of readline is not available (obviously)
// so that e.g. the GAP banner reports this correctly.
SyUseReadline = 0;
#else
// don't use readline if in Window mode (e.g. for XGAP)
if (SyWindow)
SyUseReadline = 0;
// don't use readline if stdin is not attached to a terminal
else if (!isatty(fileno(stdin)))
SyUseReadline = 0;
#endif
if (SyWindow) SyUseReadline = 0;

InitSysFiles();

/* now that the user has had a chance to give -x and -y,
we determine the size of the screen ourselves */
Expand Down

0 comments on commit 3bcd162

Please sign in to comment.