diff options
author | Alexander Naumov <alexander_naumov@opensuse.org> | 2017-01-24 23:52:21 +0100 |
---|---|---|
committer | Alexander Naumov <alexander_naumov@opensuse.org> | 2017-01-24 23:52:21 +0100 |
commit | 2141512c94bbab0ad0c1f5bb87e8c761f506ac0d (patch) | |
tree | a4fb598b9f40b930f3e944fc057e47d43d095692 | |
parent | 9054e9fc4a3514e717152aaf6464863a5cfdd306 (diff) | |
download | screen-2141512c94bbab0ad0c1f5bb87e8c761f506ac0d.tar.gz |
Replace screenlogfile only if it's needed
-rw-r--r-- | src/screen.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/screen.c b/src/screen.c index 5cf23e1..641d889 100644 --- a/src/screen.c +++ b/src/screen.c @@ -668,17 +668,18 @@ int main(int ac, char** av) case 'L': if (--ac != 0) { - screenlogfile = SaveStr(*++av); - if (screenlogfile[0] == '-') - screenlogfile = SaveStr("screenlog.%n"); - if (strlen(screenlogfile) > PATH_MAX) + char *newlogfile = SaveStr(*++av); + if (strlen(newlogfile) > PATH_MAX) Panic(0, "-L: logfile name too long. (max. %d char)", PATH_MAX); FILE *w_check; - if ((w_check = fopen(screenlogfile, "w")) == NULL) + if ((w_check = fopen(newlogfile, "w")) == NULL) Panic(0, "-L: logfile name access problem"); else fclose(w_check); + + if (newlogfile[0] != '-') + screenlogfile = newlogfile; } nwin_options.Lflag = 1; break; |