From 59be608802e2ea1002b644bd81cff816aa881b68 Mon Sep 17 00:00:00 2001 From: Paul Traina Date: Thu, 8 Sep 1994 19:27:06 +0000 Subject: [PATCH] Add code to pull options out of FINGER environment variable if present. Yes, has same stupid bug as more(1), options must be specified as one argument. Submitted by: pst --- usr.bin/finger/finger.1 | 8 ++++++++ usr.bin/finger/finger.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1 index 306aa74c9d0..74a1a5a2d1b 100644 --- a/usr.bin/finger/finger.1 +++ b/usr.bin/finger/finger.1 @@ -173,6 +173,14 @@ style. The .Fl l option is the only option that may be passed to a remote machine. +.Sh ENVIRONMENT +.Nm Finger +utilizes the following environment variable, if it exists: +.Bl -tag -width Fl +.It Ev FINGER +This variable may be set with favored options to +.Nm finger . +.El .Sh SEE ALSO .Xr chpass 1 , .Xr w 1 , diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index aaef07bc987..2bf070435fb 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -88,14 +88,14 @@ char tbuf[1024]; static void loginlist __P((void)); static void userlist __P((int, char **)); -main(argc, argv) +int +option(argc, argv) int argc; char **argv; { int ch; - /* delete this for sun behavior */ - oflag = 1; /* default to old behavior for now */ + optind = 1; /* reset getopt */ while ((ch = getopt(argc, argv, "lmpsho")) != EOF) switch(ch) { @@ -123,8 +123,33 @@ main(argc, argv) "usage: finger [-lmpsho] [login ...]\n"); exit(1); } - argc -= optind; - argv += optind; + + return optind; +} + +main(argc, argv) + int argc; + char **argv; +{ + int ch, envargc, argcnt; + char *envargv[3]; + + /* remove this line to get remote host */ + oflag = 1; /* default to old "office" behavior */ + + /* + * Process environment variables followed by command line arguments. + */ + if ((envargv[1] = getenv("FINGER"))) { + envargc = 2; + envargv[0] = "finger"; + envargv[2] = NULL; + (void) option(envargc, envargv); + } + + argcnt = option(argc, argv); + argc -= argcnt; + argv += argcnt; (void)time(&now); setpassent(1);