| 1 | '\" |
|---|
| 2 | '\" Copyright (c) 1995-1996 Sun Microsystems, Inc. |
|---|
| 3 | '\" |
|---|
| 4 | '\" See the file "license.terms" for information on usage and redistribution |
|---|
| 5 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
|---|
| 6 | '\" |
|---|
| 7 | '\" RCS: @(#) $Id: FindExec.3,v 1.7 2004/10/07 15:15:38 dkf Exp $ |
|---|
| 8 | '\" |
|---|
| 9 | .so man.macros |
|---|
| 10 | .TH Tcl_FindExecutable 3 8.1 Tcl "Tcl Library Procedures" |
|---|
| 11 | .BS |
|---|
| 12 | .SH NAME |
|---|
| 13 | Tcl_FindExecutable, Tcl_GetNameOfExecutable \- identify or return the name of the binary file containing the application |
|---|
| 14 | .SH SYNOPSIS |
|---|
| 15 | .nf |
|---|
| 16 | \fB#include <tcl.h>\fR |
|---|
| 17 | .sp |
|---|
| 18 | void |
|---|
| 19 | \fBTcl_FindExecutable\fR(\fIargv0\fR) |
|---|
| 20 | .sp |
|---|
| 21 | const char * |
|---|
| 22 | \fBTcl_GetNameOfExecutable\fR() |
|---|
| 23 | .SH ARGUMENTS |
|---|
| 24 | .AS char *argv0 |
|---|
| 25 | .AP char *argv0 in |
|---|
| 26 | The first command-line argument to the program, which gives the |
|---|
| 27 | application's name. |
|---|
| 28 | .BE |
|---|
| 29 | |
|---|
| 30 | .SH DESCRIPTION |
|---|
| 31 | .PP |
|---|
| 32 | The \fBTcl_FindExecutable\fR procedure computes the full path name of |
|---|
| 33 | the executable file from which the application was invoked and saves |
|---|
| 34 | it for Tcl's internal use. |
|---|
| 35 | The executable's path name is needed for several purposes in |
|---|
| 36 | Tcl. For example, it is needed on some platforms in the |
|---|
| 37 | implementation of the \fBload\fR command. |
|---|
| 38 | It is also returned by the \fBinfo nameofexecutable\fR command. |
|---|
| 39 | .PP |
|---|
| 40 | On UNIX platforms this procedure is typically invoked as the very |
|---|
| 41 | first thing in the application's main program; it must be passed |
|---|
| 42 | \fIargv[0]\fR as its argument. It is important not to change the |
|---|
| 43 | working directory before the invocation. |
|---|
| 44 | \fBTcl_FindExecutable\fR uses \fIargv0\fR |
|---|
| 45 | along with the \fBPATH\fR environment variable to find the |
|---|
| 46 | application's executable, if possible. If it fails to find |
|---|
| 47 | the binary, then future calls to \fBinfo nameofexecutable\fR |
|---|
| 48 | will return an empty string. |
|---|
| 49 | .PP |
|---|
| 50 | \fBTcl_GetNameOfExecutable\fR simply returns a pointer to the |
|---|
| 51 | internal full path name of the executable file as computed by |
|---|
| 52 | \fBTcl_FindExecutable\fR. This procedure call is the C API |
|---|
| 53 | equivalent to the \fBinfo nameofexecutable\fR command. NULL |
|---|
| 54 | is returned if the internal full path name has not been |
|---|
| 55 | computed or unknown. |
|---|
| 56 | |
|---|
| 57 | .SH KEYWORDS |
|---|
| 58 | binary, executable file |
|---|