diff options
author | Sami Kerola | 2014-07-27 19:01:09 +0200 |
---|---|---|
committer | Sami Kerola | 2014-07-28 22:15:18 +0200 |
commit | 3d9f4b1d234e4a38ac6a5619c4cd93fc66d1d4c6 (patch) | |
tree | a46f7d8fc8e77a1c29e1f1324583e5f409030a00 /misc-utils/logger.c | |
parent | logger: improve readablity of pencode() function (diff) | |
download | kernel-qcow2-util-linux-3d9f4b1d234e4a38ac6a5619c4cd93fc66d1d4c6.tar.gz kernel-qcow2-util-linux-3d9f4b1d234e4a38ac6a5619c4cd93fc66d1d4c6.tar.xz kernel-qcow2-util-linux-3d9f4b1d234e4a38ac6a5619c4cd93fc66d1d4c6.zip |
logger: warn when --file and command line message are combined
When --file is combined with command line arguments the later has
silently been ignored. This commit makes user to be aware the logger
will not use command line arguments when --file is specified.
Reported-by: "Daniel 'DaB.' Baur" <debian@daniel.baur4.info>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467244
CC: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r-- | misc-utils/logger.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c index afd93712a..ac583fd10 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -535,6 +535,7 @@ int main(int argc, char **argv) .rfc5424_host = 1, }; int ch; + int stdout_reopened = 0; #ifdef HAVE_LIBSYSTEMD FILE *jfd = NULL; #endif @@ -570,8 +571,8 @@ int main(int argc, char **argv) switch (ch) { case 'f': /* file to log */ if (freopen(optarg, "r", stdin) == NULL) - err(EXIT_FAILURE, _("file %s"), - optarg); + err(EXIT_FAILURE, _("file %s"), optarg); + stdout_reopened = 1; break; case 'i': /* log process id also */ ctl.logflags |= LOG_PID; @@ -642,6 +643,8 @@ int main(int argc, char **argv) } argc -= optind; argv += optind; + if (stdout_reopened && argc) + warnx(_("--file <file> and <message> are mutually exclusive, message is ignored")); #ifdef HAVE_LIBSYSTEMD if (jfd) { int ret = journald_entry(jfd); |