doc: Update documentation about 'progname' module.
[gnulib.git] / doc / progname.texi
blob13c9c7ba9792fe488a996495fd5211ec6a1340a0
1 @node progname and getprogname
2 @section progname and getprogname
4 @c Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
6 @c Permission is granted to copy, distribute and/or modify this document
7 @c under the terms of the GNU Free Documentation License, Version 1.3 or
8 @c any later version published by the Free Software Foundation; with no
9 @c Invariant Sections, no Front-Cover Texts, and no Back-Cover
10 @c Texts.  A copy of the license is included in the ``GNU Free
11 @c Documentation License'' file as part of this distribution.
13 Gnulib has two modules for retrieving the name of the currently executing
14 program: @code{progname} and @code{getprogname}.
16 @findex progname
17 @vindex program_name
18 The @code{progname} module defines a variable @code{program_name}.
19 It contains the name of the currently executing program, on all platforms.
20 But it cannot be used implicitly:  It requires that every @code{main}
21 function be modified to invoke @code{set_program_name (argv[0])} as one
22 of its first actions.
24 @findex getprogname
25 The @code{getprogname} module defines a function @code{getprogname()}.
26 It returns the name of the currently executing program, on most platforms.
27 The advantage of this module is that it can be used without prior
28 initializations.  But it has limitations:  In some rare situations, it
29 cannot determine the name; then it returns @code{"?"} instead.  And on
30 some platforms, it returns a truncated program name.
32 @findex error
33 The @code{error} function uses the @code{getprogname} module.