Implementing a -Ver option

Learn how to implement the -Ver option.

You need not depend on the what command to extract version information from your executable. Instead, you can have the program itself output the information stored in the version_string and version_time variables. Revise the source module that does command-line processing to support a what version option (for example, -Ver):

#include <stdio.h>

main(argc,argv)
    int argc;
    char **argv;
{
/*
 * implement -Ver option
 */
    if (argc > 1 && strcmp(argv[1],"-Ver") == 0) {
        extern char *version_string;
        extern char *version_time;
        /*
         * Print version info, skipping the "@(#)" characters
         */
        printf ("%s (%s)\n",
                    &version_string[4], &version_time[4]);
        exit(0);
    }
}