2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

added -v flag and usage()

This commit is contained in:
Todd C. Miller 1994-05-25 03:08:45 +00:00
parent 51ae4df137
commit 6e7d42f3e1

View File

@ -55,6 +55,7 @@ static char rcsid[] = "$Id$";
#include <sys/file.h>
#include "sudo.h"
#include "version.h"
#ifndef STDC_HEADERS
extern char *getenv();
@ -66,6 +67,7 @@ extern int errno, yylineno;
/*
* Globals
*/
char **Argv;
char buffer[BUFSIZ];
char *sudoers = _PATH_SUDO_SUDOERS;
char *sudoers_tmp_file = _PATH_SUDO_STMP;
@ -74,6 +76,12 @@ int status = 0,
FILE *sudoers_tmp_fp=NULL,
*sudoers_fp=NULL;
/*
* local functions not visible outside visudo.c
*/
static void usage();
static RETSIGTYPE Exit(sig)
int sig;
{
@ -95,6 +103,21 @@ main(argc, argv)
char * Editor;
#endif /* ENV_EDITOR */
Argv = argv;
if (argc > 1) {
/*
* print version string and exit if we got -v
*/
if (!strcmp(argv[1], "-v")) {
(void) printf("visudo version %s\n", version);
exit(0);
} else {
usage();
}
}
/*
* handle the signals
*/
@ -239,3 +262,17 @@ main(argc, argv)
exit(0);
}
}
/**********************************************************************
*
* usage()
*
* this function just gives you instructions and exits
*/
static void usage()
{
(void) fprintf(stderr, "usage: %s [-v]\n", *Argv);
exit(1);
}