summaryrefslogtreecommitdiffstats
path: root/login-utils/last.c
diff options
context:
space:
mode:
authorSami Kerola2015-10-06 23:18:27 +0200
committerSami Kerola2015-10-18 19:03:34 +0200
commitf06abd22beedcfe5dbd5577180bbed0a98d4f8dc (patch)
tree84010ac4eb9a5fb850b9da6492ba75582536b05e /login-utils/last.c
parentscript: be pedantic and use "%"SCNi64 (diff)
downloadkernel-qcow2-util-linux-f06abd22beedcfe5dbd5577180bbed0a98d4f8dc.tar.gz
kernel-qcow2-util-linux-f06abd22beedcfe5dbd5577180bbed0a98d4f8dc.tar.xz
kernel-qcow2-util-linux-f06abd22beedcfe5dbd5577180bbed0a98d4f8dc.zip
last: display input file in usage() according to command name
Default depends on whether the executable is called 'lastb' or something else. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r--login-utils/last.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/login-utils/last.c b/login-utils/last.c
index 8d82c106e..dbfa8aed1 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -543,7 +543,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(const struct last_control *ctl, FILE *out)
{
fputs(USAGE_HEADER, out);
fprintf(out, _(
@@ -557,7 +557,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -a, --hostlast display hostnames in the last column\n"), out);
fputs(_(" -d, --dns translate the IP number back into a hostname\n"), out);
fprintf(out,
- _(" -f, --file <file> use a specific file instead of %s\n"), _PATH_WTMP);
+ _(" -f, --file <file> use a specific file instead of %s\n"), ctl->lastb ? _PATH_BTMP : _PATH_WTMP);
fputs(_(" -F, --fulltimes print full login and logout times and dates\n"), out);
fputs(_(" -i, --ip display IP numbers in numbers-and-dots notation\n"), out);
fputs(_(" -n, --limit <number> how many lines to show\n"), out);
@@ -911,7 +911,10 @@ int main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
atexit(close_stdout);
-
+ /*
+ * Which file do we want to read?
+ */
+ ctl.lastb = strcmp(program_invocation_short_name, "lastb") == 0 ? 1 : 0;
while ((c = getopt_long(argc, argv,
"hVf:n:RxadFit:p:s:0123456789w", long_opts, NULL)) != -1) {
@@ -919,7 +922,7 @@ int main(int argc, char **argv)
switch(c) {
case 'h':
- usage(stdout);
+ usage(&ctl, stdout);
break;
case 'V':
printf(UTIL_LINUX_VERSION);
@@ -979,7 +982,7 @@ int main(int argc, char **argv)
ctl.time_fmt = which_time_format(optarg);
break;
default:
- usage(stderr);
+ usage(&ctl, stderr);
break;
}
}
@@ -987,10 +990,6 @@ int main(int argc, char **argv)
if (optind < argc)
ctl.show = argv + optind;
- /*
- * Which file do we want to read?
- */
- ctl.lastb = strcmp(program_invocation_short_name, "lastb") == 0 ? 1 : 0;
if (!files) {
files = xmalloc(sizeof(char *));
files[nfiles++] = xstrdup(ctl.lastb ? _PATH_BTMP : _PATH_WTMP);