Previous: val, Up: Invoking CSSC Programs


3.16 what

The what program is designed to search in files for the recognition string ‘@(#)’. All the strings it finds matching this are printed on standard output.

The exit status of what if zero is a matching string as found, and 1 otherwise.

3.16.1 Options for what

what [-s] [-V] file [file ...]

-s
Exit successfully after finding the first string.
-V
Show version information for what.

3.16.2 Example

While the file is being edited (either at first or after ‘get -e’):-

     #ifndef CONFIG_NO_SCCS_IDS
     static const char sccs_id[] = "%W%";
     #endif

When the file is checked out for compiling (with get):-

     #ifndef CONFIG_NO_SCCS_IDS
     static const char sccs_id[] = "@(#)foo.c        1.3";
     #endif

After compiling:-

     $ what foo
     foo:
             foo.c       1.3

If the executable is linked from several source files, you will get a line of output for each string containing the identification string ‘@(#)’. This is useful for finding out exactly what code went into an executable. This technique also works on object files, archive libraries, text files, and in fact any sorts of files at all.

Unlike the strings command, there is no way to make what operate on standard input. The data would need to be written to a file first.

The rationale for the preprocessor construct CONFIG_NO_SCCS_IDS is that sometimes compilers or lint-pickers complain that the variable sccs_id is unused, and defining CONFIG_NO_SCCS_IDS will remove these ids and thus silence the warnings.