Files
tcl/doc/FindExec.3
2026-01-09 06:38:00 +00:00

70 lines
2.6 KiB
Groff

'\"
'\" Copyright (c) 1995-1996 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH Tcl_FindExecutable 3 9.1 Tcl "Tcl Library Procedures"
.so man.macros
.BS
.SH NAME
Tcl_FindExecutable, Tcl_GetNameOfExecutable \- identify or return the name of the binary file containing the application
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
const char *
\fBTcl_FindExecutable\fR(\fIargv0\fR)
.sp
const char *
\fBTcl_GetNameOfExecutable\fR()
.fi
.SH ARGUMENTS
.AS char *argv0
.AP char *argv0 in
The first command-line argument to the program, which gives the
application's name.
.BE
.SH DESCRIPTION
.PP
\fBTcl_FindExecutable\fR is one of two functions, \fBTclZipfs_AppHook\fR
being the other, that must be called by an application to initialize
Tcl prior to any other calls into Tcl. Applications that wish to use
ZipFS-based builds should call \fBTclZipfs_AppHook\fR in preference
to this function.
.PP
On UNIX platforms, the function should be passed \fIargv[0]\fR as its
argument. It is important not to change the working directory before
this invocation. \fBTcl_FindExecutable\fR uses \fIargv0\fR together
with the \fBPATH\fR environment variable to locate the application's
executable, if possible. If it fails to find the binary, subsequent
calls to \fBinfo nameofexecutable\fR will return an empty string.
.PP
On Windows platforms, the \fIargv[0]\fR argument is used only to
indicate whether the executable has a standard error channel (any
non-null value) or not (the value null). If \fBTcl_SetPanicProc\fR is
never called and no debugger is running, this setting determines
whether a panic message is sent to standard error or displayed in a
system dialog.
.PP
As part of its initialization sequence,
\fBTcl_FindExecutable\fR computes the full path name of the executable
file from which the application was invoked. This result is saved for
Tcl's internal use and is returned by the
\fBinfo nameofexecutable\fR command.
.PP
The result of \fBTcl_FindExecutable\fR is the full Tcl version string,
including build information (for example,
\fB9.0.0+abcdef...abcdef.gcc-1002\fR).
.PP
\fBTcl_GetNameOfExecutable\fR simply returns a pointer to the
internal full path name of the executable file as computed by
\fBTcl_FindExecutable\fR. This procedure call is the C API
equivalent to the \fBinfo nameofexecutable\fR command. NULL
is returned if the internal full path name has not been
computed or unknown.
.PP
\fBTcl_FindExecutable\fR can not be used in stub-enabled extensions.
.SH KEYWORDS
binary, executable file