comparison src/defaults.cc @ 11294:e2a4f3478b7c

datetick.m: add missing semicolon
author John W. Eaton <jwe@octave.org>
date Thu, 25 Nov 2010 02:18:58 -0500
parents 89f4d7e294cc
children cb94bdc74670
comparison
equal deleted inserted replaced
11293:202bd0f1863d 11294:e2a4f3478b7c
225 { 225 {
226 Vbin_dir = subst_octave_home (OCTAVE_BINDIR); 226 Vbin_dir = subst_octave_home (OCTAVE_BINDIR);
227 } 227 }
228 228
229 void 229 void
230 set_exec_path (const std::string& path) 230 set_exec_path (const std::string& path_arg)
231 { 231 {
232 VEXEC_PATH = Vlocal_ver_arch_lib_dir + dir_path::path_sep_str () 232 std::string tpath = path_arg;
233 + Vlocal_api_arch_lib_dir + dir_path::path_sep_str () 233
234 + Vlocal_arch_lib_dir + dir_path::path_sep_str () 234 if (tpath.empty ())
235 + Varch_lib_dir + dir_path::path_sep_str () 235 tpath = octave_env::getenv ("OCTAVE_EXEC_PATH");
236 + Vbin_dir; 236
237 237 if (tpath.empty ())
238 tpath = Vlocal_ver_arch_lib_dir + dir_path::path_sep_str ()
239 + Vlocal_api_arch_lib_dir + dir_path::path_sep_str ()
240 + Vlocal_arch_lib_dir + dir_path::path_sep_str ()
241 + Varch_lib_dir + dir_path::path_sep_str ()
242 + Vbin_dir;
243
244 VEXEC_PATH = tpath;
245
246 // FIXME -- should we really be modifying PATH in the environment?
247 // The way things are now, Octave will ignore directories set in the
248 // PATH with calls like
249 //
250 // setenv ("PATH", "/my/path");
251 //
252 // To fix this, I think Octave should be searching the combination of
253 // PATH and EXEC_PATH for programs that it executes instead of setting
254 // the PATH in the environment and relying on the shell to do the
255 // searching.
256
238 // This is static so that even if set_exec_path is called more than 257 // This is static so that even if set_exec_path is called more than
239 // once, shell_path is the original PATH from the environment, 258 // once, shell_path is the original PATH from the environment,
240 // before we start modifying it. 259 // before we start modifying it.
241 static std::string shell_path = octave_env::getenv ("PATH"); 260 static std::string shell_path = octave_env::getenv ("PATH");
242 261
243 if (! shell_path.empty ()) 262 if (! shell_path.empty ())
244 VEXEC_PATH += dir_path::path_sep_str () + shell_path; 263 tpath = shell_path + dir_path::path_sep_str () + tpath;
245 264
246 std::string tpath = path; 265 octave_env::putenv ("PATH", tpath);
247
248 if (tpath.empty ())
249 tpath = octave_env::getenv ("OCTAVE_EXEC_PATH");
250
251 if (! tpath.empty ())
252 VEXEC_PATH = tpath + dir_path::path_sep_str () + VEXEC_PATH;
253
254 octave_env::putenv ("PATH", VEXEC_PATH);
255 } 266 }
256 267
257 void 268 void
258 set_image_path (const std::string& path) 269 set_image_path (const std::string& path)
259 { 270 {
412 DEFUN (EXEC_PATH, args, nargout, 423 DEFUN (EXEC_PATH, args, nargout,
413 "-*- texinfo -*-\n\ 424 "-*- texinfo -*-\n\
414 @deftypefn {Built-in Function} {@var{val} =} EXEC_PATH ()\n\ 425 @deftypefn {Built-in Function} {@var{val} =} EXEC_PATH ()\n\
415 @deftypefnx {Built-in Function} {@var{old_val} =} EXEC_PATH (@var{new_val})\n\ 426 @deftypefnx {Built-in Function} {@var{old_val} =} EXEC_PATH (@var{new_val})\n\
416 Query or set the internal variable that specifies a colon separated\n\ 427 Query or set the internal variable that specifies a colon separated\n\
417 list of directories to search when executing external programs.\n\ 428 list of directories to append to the shell PATH when executing external\n\
418 Its initial value is taken from the environment variable\n\ 429 programs. The initial value of is taken from the environment variable\n\
419 @w{@env{OCTAVE_EXEC_PATH}} (if it exists) or @env{PATH}, but that\n\ 430 @w{@env{OCTAVE_EXEC_PATH}}, but that value can be overridden by\n\
420 value can be overridden by the command line argument\n\ 431 the command line argument @option{--exec-path PATH}.\n\
421 @option{--exec-path PATH}. At startup, an additional set of\n\
422 directories (including the shell PATH) is appended to the path\n\
423 specified in the environment or on the command line. If you use\n\
424 the @w{@env{EXEC_PATH}} function to modify the path, you should take\n\
425 care to preserve these additional directories.\n\
426 @end deftypefn") 432 @end deftypefn")
427 { 433 {
428 std::string saved_exec_path = VEXEC_PATH;
429
430 octave_value retval = SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EXEC_PATH); 434 octave_value retval = SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EXEC_PATH);
431 435
432 if (VEXEC_PATH != saved_exec_path) 436 set_exec_path (VEXEC_PATH);
433 octave_env::putenv ("PATH", VEXEC_PATH);
434 437
435 return retval; 438 return retval;
436 } 439 }
437 440
438 DEFUN (IMAGE_PATH, args, nargout, 441 DEFUN (IMAGE_PATH, args, nargout,