1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

EOF by 2 ^D on a TTY

Terminate the input from a TTY by 2 ^D at the middle of line, like
as many programs, `cat`, `perl` and so on, do.  By the first ^D,
the line will be sent without a newline, and then EOF will be send
by the next ^D.
This commit is contained in:
Nobuyoshi Nakada 2019-06-04 09:24:17 +09:00
parent 9a07915ae2
commit aa8d393d8a
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 5 additions and 1 deletions

View file

@ -6015,6 +6015,10 @@ nextline(struct parser_params *p)
if (p->eofp)
return -1;
if (p->lex.pend > p->lex.pbeg && *(p->lex.pend-1) != '\n') {
goto end_of_input;
}
if (!p->lex.input || NIL_P(v = lex_getline(p))) {
end_of_input:
p->eofp = 1;

2
ruby.c
View file

@ -2011,7 +2011,7 @@ load_file_internal(VALUE argp_v)
else if (!NIL_P(c)) {
rb_io_ungetbyte(f, c);
}
else {
if (NIL_P(c)) {
argp->f = f = Qnil;
}
if (!(opt->dump & ~DUMP_BIT(version_v))) {