diff options
author | Alexander Naumov <alexander_naumov@opensuse.org> | 2017-01-26 23:44:43 +0100 |
---|---|---|
committer | Alexander Naumov <alexander_naumov@opensuse.org> | 2017-01-26 23:44:43 +0100 |
commit | d6c724ad5348c529b87df6fd9be817e1f495451e (patch) | |
tree | 21ba5aef32aabfb0bdc6919b2913f1d82e916b87 | |
parent | 2141512c94bbab0ad0c1f5bb87e8c761f506ac0d (diff) | |
download | screen-d6c724ad5348c529b87df6fd9be817e1f495451e.tar.gz |
Adding "-L logfile" option for setting new logfile's name
Now it's possible to set your own lofile name with
this option ONLY. It fixes also API of old versions.
-rw-r--r-- | src/doc/screen.1 | 9 | ||||
-rw-r--r-- | src/screen.c | 23 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/doc/screen.1 b/src/doc/screen.1 index eabd763..5b14d91 100644 --- a/src/doc/screen.1 +++ b/src/doc/screen.1 @@ -261,9 +261,12 @@ Ask your system administrator if you are not sure. Remove sessions with the .B \-L tells .I screen -to turn on automatic output logging for the windows. By default, logfile's name -is screenlog.0. You can set new name: add it right after -L option e.g. "screen --L my_logfile". Keep in mind that name can not start with "-" symbol. +to turn on automatic output logging for the windows. +.TP 5 +.BI "\-L logfile " file +By default logfile name is \*Qscreenlog.0\*Q. You can also set new logfile name +with the \*Qlogfile\*Q option. Keep in mind that logfile name can not start with +the "-" symbol. .TP 5 .B \-m causes diff --git a/src/screen.c b/src/screen.c index 641d889..9e1072a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -667,19 +667,16 @@ int main(int ac, char** av) break; case 'L': - if (--ac != 0) { - 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(newlogfile, "w")) == NULL) - Panic(0, "-L: logfile name access problem"); - else - fclose(w_check); - - if (newlogfile[0] != '-') - screenlogfile = newlogfile; + if (--ac > 0 && !strcmp(*++av, "logfile")) { + *++av; // Now '*av' is a logfile parameter + + if (strlen(*av) > PATH_MAX) + Panic(1, "-L: logfile name too long. (max. %d char)", PATH_MAX); + + if (*av[0] == '-') + Panic(0, "-L: logfile name can not start with \"-\" symbol"); + + screenlogfile = SaveStr(*av); } nwin_options.Lflag = 1; break; |