diff options
author | pst <pst@FreeBSD.org> | 1994-09-08 19:27:06 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1994-09-08 19:27:06 +0000 |
commit | 93cbf671fafa6bf4f695e75465c25fffd5cb5b20 (patch) | |
tree | e17290c5908d1bcd154a8771091f7aa8d048ec70 /usr.bin/finger | |
parent | e41fdd479ecb19c33c6c82b35c42df8f865e52c9 (diff) | |
download | FreeBSD-src-93cbf671fafa6bf4f695e75465c25fffd5cb5b20.zip FreeBSD-src-93cbf671fafa6bf4f695e75465c25fffd5cb5b20.tar.gz |
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
Diffstat (limited to 'usr.bin/finger')
-rw-r--r-- | usr.bin/finger/finger.1 | 8 | ||||
-rw-r--r-- | 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 306aa74..74a1a5a 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 aaef07b..2bf0704 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); |