2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: dtksh.c /main/3 1995/11/01 15:53:19 rswiston $ */
24 /* Copyright (c) 1991, 1992 UNIX System Laboratories, Inc. */
25 /* All Rights Reserved */
27 /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
28 /* UNIX System Laboratories, Inc. */
29 /* The copyright notice above does not evidence any */
30 /* actual or intended publication of such source code. */
39 #define CONSTCHAR (const char *)
44 #define DTKSHBINDIR "/usr/bin"
54 sprintf(path, "%s/%s", dir, file);
55 return(stat(path, &sbuf) != -1);
59 * Bootstrap dtksh by calling xmcoeksh and forcing it to execute
60 * an rc file that calls the dtksh init function and does some
61 * other minor housekeeping.
63 * The rc file then sees if there was a previous user rc file (in $_HOLDENV_)
64 * and if so executes it.
74 char *executable, *envfile;
79 * Set the ENV variable to the standard dtksh rc file, which
80 * will do a libdirload of the dtksh shared object file and add all
81 * the dtksh commands and widgets to the exksh. If the user already
82 * had an ENV file, then set the variable _HOLDENV_ to it so the
83 * standard dtksh rc file can execute it later.
85 env = getenv((const char *)"ENV");
86 buf = (char *)malloc((env ? strlen(env) : 0) + 12);
87 strcpy(buf, "_HOLDENV_=");
88 strcat(buf, env ? env : "");
91 executable = "xmcoeksh";
92 envfile = "xmcoeksh.rc";
95 * Search order for DTKSH binaries:
97 * 1. if $DTKSHBINDIR is set, use that path if it exists.
98 * 2. if the hard-wired #define DTKSHBINDIR is set and is a
99 * readable directory, use it.
103 if ((bindir = getenv((const char *)"DTKSHBINDIR")) != NULL) {
104 if ((!FileExists(bindir, executable)) ||
105 (!FileExists(bindir, envfile)))
113 bindir = DTKSHBINDIR;
115 if ((!FileExists(bindir, executable)) ||
116 (!FileExists(bindir, envfile)))
122 if (bindir == NULL) {
124 "dtksh: bootstrap failed. Unable to locate both\nxmcoeksh and xmcoeksh.rc in the same directory.\n Try setting $DTKSHBINDIR.\n");
127 sprintf(envbuf, "DTKSHBINDIR=%s", bindir);
128 putenv(strdup(envbuf));
130 sprintf(envbuf, "ENV=%s/%s", bindir, envfile);
131 putenv(strdup(envbuf));
132 sprintf(envbuf, "%s/%s", bindir, executable);
135 fprintf(stderr, "dtksh: Bootstrap of dtksh failed: '%s'\n", envbuf);
137 return(1); /* failure */