Home

arg0

Arg0 is a conventional label for the first entry in an argument vector provided to a program at startup. In most environments it stores the name or path used to invoke the program, and is distinct from subsequent arguments to the program.

In C and C++ programs, the main function commonly has the signature int main(int argc, char *argv[]).

In Python, sys.argv[0] is the script or module being executed, with subsequent items in sys.argv representing

Notes: The value of arg0 is implementation-dependent and is not standardized across languages. Some runtimes do

See also: argv, argc, main, command-line interface.

The
element
argv[0]
contains
the
program
name
or
the
path
used
to
execute
it;
argc
includes
that
initial
entry
along
with
any
additional
arguments.
In
practice,
argv[0]
may
be
a
full
path,
a
relative
path,
or
only
the
executable
name,
and
it
can
differ
from
the
binary’s
actual
file
location
if
invoked
via
a
symlink
or
via
a
shell
wrapper.
the
remaining
arguments.
In
many
Unix
shells,
$0
holds
the
script
or
command
name
and
$1,
$2,
etc.
the
positional
parameters.
The
exact
handling
of
arg0
varies
by
language
and
runtime,
and
not
all
environments
expose
a
separate
argv[0]
in
the
same
way.
not
expose
a
distinct
program-name
entry
or
may
omit
it
from
the
argument
list.
Arg0
is
commonly
used
to
derive
resource
paths
relative
to
the
program’s
location
or
to
display
usage
and
error
messages
that
reference
the
program’s
name.