Earlier when typescript file failed new line after the error did not cause carriage return. Here is an example how prompt> travels to wrong place: prompt> script 0500-perms/typescript Script started, file is 0500-perms/typescript script: cannot open 0500-perms/typescript: Permission denied prompt> But that wasn't quite as bad as what happen with timing file, that at failure left terminal to state where a reset(1) run was needed. Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- term-utils/script.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/term-utils/script.c b/term-utils/script.c index f2fc2f59c..be869654e 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -423,15 +423,27 @@ static void do_io(struct script_control *ctl) if ((ctl->typescriptfp = fopen(ctl->fname, ctl->append ? "a" UL_CLOEXECSTR : "w" UL_CLOEXECSTR)) == NULL) { + struct termios rtt; + + rtt = ctl->attrs; + tcsetattr(STDIN_FILENO, TCSANOW, &rtt); warn(_("cannot open %s"), ctl->fname); fail(ctl); } if (ctl->timing) { - if (!ctl->tname) { - if (!(ctl->timingfp = fopen("/dev/stderr", "w" UL_CLOEXECSTR))) - err(EXIT_FAILURE, _("cannot open %s"), "/dev/stderr"); - } else if (!(ctl->timingfp = fopen(ctl->tname, "w" UL_CLOEXECSTR))) - err(EXIT_FAILURE, _("cannot open %s"), ctl->tname); + char *tname; + if (ctl->tname) + tname = ctl->tname; + else + tname = "/dev/stderr"; + if (!(ctl->timingfp = fopen(tname, "w" UL_CLOEXECSTR))) { + struct termios rtt; + + rtt = ctl->attrs; + tcsetattr(STDIN_FILENO, TCSANOW, &rtt); + warn(_("cannot open %s"), tname); + fail(ctl); + } } -- 2.13.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html