GLOBAL(1)

NAME
global - print the locations of specified object.

SYNOPSIS
global [-alrvx] pattern
global -c [prefix]
global -f[arx] file
global -g[alvx] pattern
global -i[v]
global -p
global -s[alvx] pattern

DESCRIPTION
Global find the locations of specified object in C and Yacc source files. Global can treat a source tree, that is, a directory that has subdirectories and source files. You can get the relative path of objects from anywhere within the tree. Global can locate not only function definitions but also function references and other symbols. Duplicate entries are allowed.

In advance of using this command, you must execute gtags(1) at the root directory of the source tree to make tag files. Then you can execute global at anywhere in the source tree.

The following options are available:

pattern
    object pattern. It can include POSIX 1003.2 regular expression.

-a  print absolute path name. By default, print relative path name.

-c [prefix]
    print candidate function names which start with specified prefix. If prefix is not specified, print all function names.

-f file
    print all function definitions in the file. This option implies -x option.

-g  print all lines which match to the pattern.

-i  reconstruct tags files incrementally.

-l  print objects which exist under the current directory.

-r  print the locations of function references. By default, print function definitions.

-p  print the location of GTAGS.

-s  print the locations of specified symbol other than function names. You need GSYMS tags file. See gtags(1).

-x  In addition to the default output, produce the line number and the line contents.

FILES
GTAGS
    tags file for function definitions.
GRTAGS
    tags file for function references.
GSYMS
    tags file for symbols other then functions.

ENVIRONMENT
The following environment variables affect the execution of global.

GTAGSROOT
    The directory which is the root of source tree.

GTAGSDBPATH
    The directory on which gtags database exist. This value is ignored when GTAGSROOT is not defined.

GTAGSLIBPATH
    If this variable is set, its value is used as the path to search for library functions. If specified function is not found in a source tree, global search in these path too.

EXAMPLES
% ls -F Makefile src/ lib/ % gtags % global main src/main.c % global -x main main 10 src/main.c main (argc, argv) { % global -x '^[sg]et' set_num 20 lib/util.c set_num(values) get_num 30 lib/util.c get_num() { % global -rx '^[sg]et' set_num 113 src/op.c set_num(32); set_num 225 src/opop.c if (set_num(0) > 0) { get_num 90 src/op.c while (get_num() > 0) { % cd lib % global -rx '^[sg]et' set_num 113 ../src/op.c set_num(32); set_num 225 ../src/opop.c if (set_num(0) > 0) { get_num 90 ../src/op.c while (get_num() > 0) { % global strlen % (cd /usr/src/sys; gtags) % setenv GTAGSLIBPATH /usr/src/sys % global strlen ../../../usr/src/sys/libkern/strlen.c % (cd /usr/src/lib; gtags) % setenv GTAGSLIBPATH /usr/src/lib:/usr/src/sys % global strlen ../../../usr/src/lib/libc/string/strlen.c

DIAGNOSTICS
Global exits with a non 0 value if an error occurred, 0 otherwise.

SEE ALSO
btreeop(1), gtags(1), htags(1), vi(1).

AUTHORS
Shigio Yamaguchi (shigio@wafu.netgate.net)

HISTORY
The global command appeared in FreeBSD 2.2.2.