diff options
author | Karel Zak | 2016-05-18 15:06:31 +0200 |
---|---|---|
committer | Karel Zak | 2016-05-18 15:06:31 +0200 |
commit | 53ca05329127fc0c44b43f25f8c1627b4a3c33f4 (patch) | |
tree | f56b4b9b728ef08e204cec8193d322f373f7a5a1 /term-utils | |
parent | libfdisk: use table-length in dump for non-standard PT (diff) | |
download | kernel-qcow2-util-linux-53ca05329127fc0c44b43f25f8c1627b4a3c33f4.tar.gz kernel-qcow2-util-linux-53ca05329127fc0c44b43f25f8c1627b4a3c33f4.tar.xz kernel-qcow2-util-linux-53ca05329127fc0c44b43f25f8c1627b4a3c33f4.zip |
script: improve coding style and the "done" message
Don't print the "done" message if the file does not exist.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils')
-rw-r--r-- | term-utils/script.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/term-utils/script.c b/term-utils/script.c index d2eaafb8f..e90644aed 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -195,7 +195,7 @@ static void __attribute__((__noreturn__)) done(struct script_control *ctl) if (ctl->isterm) tcsetattr(STDIN_FILENO, TCSADRAIN, &ctl->attrs); - if (!ctl->quiet) + if (!ctl->quiet && ctl->typescriptfp) printf(_("Script done, file is %s\n"), ctl->fname); #ifdef HAVE_LIBUTEMPTER if (ctl->master >= 0) @@ -203,12 +203,10 @@ static void __attribute__((__noreturn__)) done(struct script_control *ctl) #endif kill(ctl->child, SIGTERM); /* make sure we don't create orphans */ - if (ctl->timingfp) - if (close_stream(ctl->timingfp) != 0) - err(EXIT_FAILURE, "write failed: %s", ctl->tname); - if (ctl->typescriptfp) - if (close_stream(ctl->typescriptfp) != 0) - err(EXIT_FAILURE, "write failed: %s", ctl->fname); + if (ctl->timingfp && close_stream(ctl->timingfp) != 0) + err(EXIT_FAILURE, "write failed: %s", ctl->tname); + if (ctl->typescriptfp && close_stream(ctl->typescriptfp) != 0) + err(EXIT_FAILURE, "write failed: %s", ctl->fname); if (ctl->rc_wanted) { if (WIFSIGNALED(ctl->childstatus)) |