Python and EOF
Richard Tobin
richard at inf.ed.ac.uk
Sat Mar 27 21:03:37 UTC 2021
> > Is it possible to make python behave correctly when the user's EOF
> > character is not set to control-D? It works fine on Linux, but not
> > with the macports on the Mac.
> >
> > For historical reasons I have control-Z as my EOF character. But
> > typing it in python results in it being suspended rather than
> > exiting. Typing control-D just echoes ^D.
> >
> > As I understand it, this is because python in macports uses libedit
> > (aka editline) rather than readline. Readline adjusts the key
> > bindings to match the user's stty settings, but libedit doesn't.
> Are you sure it's Python? Ctrl-Z is the key for putting
> the current process group into the background in shells
> that support job-control. Maybe it's the shell doing
> it.
Control-Z is the *default* suspend character, but it can be changed
using stty. I set suspend to control-X and EOF to control-Z, and I
want Python to respect this, as other programs do.
That is, I want control-Z to act as EOF and quit Python, and I want
control-X to suspend it.
Readline and editline use raw (or possibly cbreak) mode, so they have
to simulate suspend and EOF thmselves. Readline queries the suspend
and EOF characters so that it can do the right thing; editline
doesn't seem to.
-- Richard
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the macports-users
mailing list