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

Disable readline if stdin is not attached to a terminal #4495

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cmdledit.g
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ GAPInfo.UseReadline := true;
## are considered as word boundaries. The function is then installed as a
## macro and bound to the key sequence <B>Esc</B> <B>Q</B>.
## <P/>
## <Example>
## <Log>
## gap> EditAddQuotes := function(l)
## > local str, pos, i, j, new;
## > str := l[3];
Expand All @@ -264,7 +264,7 @@ GAPInfo.UseReadline := true;
## gap> InstallReadlineMacro("addquotes", EditAddQuotes);
## gap> invl := InvocationReadlineMacro("addquotes");;
## gap> ReadlineInitLine(Concatenation("\"\\eQ\":\"",invl,"\""));;
## </Example>
## </Log>
## </Subsection>
##
## </Section>
Expand Down
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