GLOBAL(1)

NAME
global - print the locations of specified object.

SYNOPSIS
global [-alnrtvx] pattern
global -c [prefix]
global -f[anrtx] files
global -g[alntvx] pattern
global -i[v]
global -p
global -P[alnt] [pattern]
global -s[alntvx] pattern

DESCRIPTION
Global find the locations of specified object in C, Yacc and Java 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.

COMMANDS
The following commands are available:

pattern
    print object which match to the pattern. It can include POSIX 1003.2 regular expression.

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

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

-g pattern
    print all lines which match to the pattern. It is similar to grep(1).

-i  locate tag files and reconstruct them incrementally.

-p  print the location of GTAGS.

-P [pattern]
    print the path which match to the pattern. If no pattern specified, print all.

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

OPTIONS
The following options are available:

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

-l  print just objects which exist under the current directory.

-n  suppress sort filter and path conversion filter.

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

-t  print with standard ctags format.

-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.
GPATH
    path index. This is used for incremental updating and compact format.

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.