2203
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2203
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2203
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <cstdlib> |
|
29 |
3503
|
30 #include <iostream> |
2203
|
31 #include <string> |
|
32 |
|
33 #ifdef HAVE_UNISTD_H |
2442
|
34 #ifdef HAVE_SYS_TYPES_H |
2203
|
35 #include <sys/types.h> |
2442
|
36 #endif |
2203
|
37 #include <unistd.h> |
|
38 #endif |
|
39 |
2926
|
40 #include "oct-env.h" |
4217
|
41 #include "file-stat.h" |
3174
|
42 #include "pathsearch.h" |
4217
|
43 #include "str-vec.h" |
2926
|
44 |
2492
|
45 #include <defaults.h> |
2203
|
46 #include "defun.h" |
|
47 #include "error.h" |
3040
|
48 #include "file-ops.h" |
2203
|
49 #include "gripes.h" |
|
50 #include "help.h" |
5395
|
51 #include "input.h" |
3185
|
52 #include "oct-obj.h" |
2390
|
53 #include "ov.h" |
4217
|
54 #include "parse.h" |
2203
|
55 #include "toplev.h" |
4217
|
56 #include "unwind-prot.h" |
2203
|
57 #include "variables.h" |
2492
|
58 #include <version.h> |
2203
|
59 |
3523
|
60 std::string Voctave_home; |
2203
|
61 |
3523
|
62 std::string Vbin_dir; |
|
63 std::string Vinfo_dir; |
|
64 std::string Vdata_dir; |
|
65 std::string Vlibexec_dir; |
|
66 std::string Varch_lib_dir; |
|
67 std::string Vlocal_arch_lib_dir; |
3597
|
68 std::string Vlocal_ver_arch_lib_dir; |
3523
|
69 std::string Vfcn_file_dir; |
5397
|
70 std::string Voct_file_dir; |
2203
|
71 |
4447
|
72 // The default path that will be searched for programs that we |
|
73 // execute (in addition to the user-specified --exec-path). |
|
74 static std::string Vdefault_exec_path; |
|
75 |
2203
|
76 // The path that will be searched for programs that we execute. |
|
77 // (--exec-path path) |
3523
|
78 std::string Vexec_path; |
2203
|
79 |
|
80 // Load path specified on command line. |
|
81 // (--path path; -p path) |
3523
|
82 static std::string Vload_path; |
2203
|
83 |
3192
|
84 // The default load path with OCTAVE_HOME appropriately substituted. |
3523
|
85 static std::string Vdefault_load_path; |
3192
|
86 |
3174
|
87 // And the cached directory path corresponding to Vload_path. |
|
88 dir_path Vload_path_dir_path; |
|
89 |
2203
|
90 // Name of the editor to be invoked by the edit_history command. |
3523
|
91 std::string Veditor; |
2203
|
92 |
3523
|
93 std::string Vimagepath; |
2203
|
94 |
3523
|
95 std::string Vlocal_site_defaults_file; |
|
96 std::string Vsite_defaults_file; |
2203
|
97 |
4776
|
98 // Name of the FFTW wisdom program. |
|
99 std::string Vfftw_wisdom_prog; |
4773
|
100 |
4217
|
101 // Each element of A and B should be directory names. For each |
|
102 // element of A not in the list B, execute SCRIPT_FILE in that |
|
103 // directory if it exists. |
|
104 |
|
105 static void |
|
106 maybe_add_or_del_packages (const string_vector& a, |
|
107 const string_vector& b, |
4247
|
108 const std::string& script_file) |
4217
|
109 { |
|
110 if (! octave_interpreter_ready) |
|
111 return; |
|
112 |
|
113 unwind_protect::begin_frame ("maybe_add_or_del_packages"); |
|
114 |
|
115 unwind_protect_bool (input_from_startup_file); |
|
116 |
|
117 input_from_startup_file = true; |
|
118 |
5275
|
119 octave_idx_type a_len = a.length (); |
|
120 octave_idx_type b_len = b.length (); |
4217
|
121 |
5275
|
122 for (octave_idx_type i = 0; i < a_len; i++) |
4217
|
123 { |
|
124 std::string a_dir = a[i]; |
|
125 |
|
126 bool found = false; |
|
127 |
5275
|
128 for (octave_idx_type j = 0; j < b_len; j++) |
4217
|
129 { |
|
130 if (b[j] == a_dir) |
|
131 { |
|
132 found = true; |
|
133 break; |
|
134 } |
|
135 } |
|
136 |
|
137 if (! found) |
|
138 { |
|
139 std::string file = a_dir + file_ops::dir_sep_str + script_file; |
|
140 |
|
141 file_stat fs = file_stat (file); |
|
142 |
|
143 if (fs.exists ()) |
4486
|
144 source_file (file); |
4217
|
145 |
|
146 if (error_state) |
|
147 return; |
|
148 } |
|
149 } |
|
150 |
|
151 unwind_protect::run_frame ("maybe_add_or_del_packages"); |
|
152 } |
|
153 |
|
154 static void |
|
155 update_load_path_dir_path (void) |
|
156 { |
|
157 string_vector old_dirs = Vload_path_dir_path.all_directories (); |
|
158 |
|
159 Vload_path_dir_path = dir_path (Vload_path, Vdefault_load_path); |
|
160 |
|
161 string_vector new_dirs = Vload_path_dir_path.all_directories (); |
|
162 |
|
163 maybe_add_or_del_packages (old_dirs, new_dirs, "PKG_DEL"); |
|
164 |
|
165 if (! error_state) |
|
166 maybe_add_or_del_packages (new_dirs, old_dirs, "PKG_ADD"); |
|
167 } |
|
168 |
|
169 void |
|
170 execute_default_pkg_add_files (void) |
|
171 { |
|
172 string_vector old_dirs; |
|
173 string_vector new_dirs = Vload_path_dir_path.all_directories (); |
|
174 |
|
175 maybe_add_or_del_packages (new_dirs, old_dirs, "PKG_ADD"); |
|
176 } |
|
177 |
3535
|
178 static std::string |
3523
|
179 subst_octave_home (const std::string& s) |
2203
|
180 { |
3523
|
181 std::string retval; |
2203
|
182 |
3523
|
183 std::string prefix = OCTAVE_PREFIX; |
2203
|
184 |
|
185 retval = s; |
|
186 |
|
187 if (Voctave_home != prefix) |
|
188 { |
5275
|
189 octave_idx_type len = prefix.length (); |
2203
|
190 size_t start = 0; |
2522
|
191 while ((start = retval.find (prefix, start)) != NPOS) |
2203
|
192 { |
|
193 retval.replace (start, len, Voctave_home); |
2522
|
194 start += len; |
2203
|
195 } |
|
196 } |
|
197 |
|
198 return retval; |
|
199 } |
|
200 |
|
201 static void |
|
202 set_octave_home (void) |
|
203 { |
3523
|
204 std::string oh = octave_env::getenv ("OCTAVE_HOME"); |
2203
|
205 |
3523
|
206 Voctave_home = oh.empty () ? std::string (OCTAVE_PREFIX) : oh; |
2203
|
207 } |
|
208 |
|
209 static void |
|
210 set_default_info_dir (void) |
|
211 { |
|
212 Vinfo_dir = subst_octave_home (OCTAVE_INFODIR); |
|
213 } |
|
214 |
|
215 static void |
3141
|
216 set_default_data_dir (void) |
|
217 { |
|
218 Vdata_dir = subst_octave_home (OCTAVE_DATADIR); |
|
219 } |
|
220 |
|
221 static void |
|
222 set_default_libexec_dir (void) |
|
223 { |
|
224 Vlibexec_dir = subst_octave_home (OCTAVE_LIBEXECDIR); |
|
225 } |
|
226 |
|
227 static void |
2203
|
228 set_default_arch_lib_dir (void) |
|
229 { |
|
230 Varch_lib_dir = subst_octave_home (OCTAVE_ARCHLIBDIR); |
|
231 } |
|
232 |
|
233 static void |
2439
|
234 set_default_local_arch_lib_dir (void) |
|
235 { |
|
236 Vlocal_arch_lib_dir = subst_octave_home (OCTAVE_LOCALARCHLIBDIR); |
|
237 } |
|
238 |
|
239 static void |
3597
|
240 set_default_local_ver_arch_lib_dir (void) |
|
241 { |
|
242 Vlocal_ver_arch_lib_dir = subst_octave_home (OCTAVE_LOCALVERARCHLIBDIR); |
|
243 } |
|
244 |
|
245 static void |
2203
|
246 set_default_fcn_file_dir (void) |
|
247 { |
|
248 Vfcn_file_dir = subst_octave_home (OCTAVE_FCNFILEDIR); |
|
249 } |
|
250 |
|
251 static void |
5397
|
252 set_default_oct_file_dir (void) |
|
253 { |
|
254 Voct_file_dir = subst_octave_home (OCTAVE_OCTFILEDIR); |
|
255 } |
|
256 |
|
257 static void |
2203
|
258 set_default_bin_dir (void) |
|
259 { |
|
260 Vbin_dir = subst_octave_home (OCTAVE_BINDIR); |
|
261 } |
|
262 |
|
263 static void |
4447
|
264 set_default_default_exec_path (void) |
|
265 { |
|
266 Vdefault_exec_path |
5777
|
267 = Vlocal_ver_arch_lib_dir + dir_path::path_sep_str |
|
268 + Vlocal_arch_lib_dir + dir_path::path_sep_str |
|
269 + Varch_lib_dir + dir_path::path_sep_str |
4447
|
270 + Vbin_dir; |
|
271 } |
|
272 |
|
273 static void |
2203
|
274 set_default_exec_path (void) |
|
275 { |
3523
|
276 std::string octave_exec_path = octave_env::getenv ("OCTAVE_EXEC_PATH"); |
2203
|
277 |
2926
|
278 if (octave_exec_path.empty ()) |
2203
|
279 { |
3523
|
280 std::string shell_path = octave_env::getenv ("PATH"); |
2203
|
281 |
2926
|
282 if (! shell_path.empty ()) |
2203
|
283 { |
5777
|
284 Vexec_path = dir_path::path_sep_str; |
2203
|
285 Vexec_path.append (shell_path); |
|
286 } |
|
287 } |
2926
|
288 else |
3523
|
289 Vexec_path = std::string (octave_exec_path); |
2203
|
290 } |
|
291 |
|
292 static void |
|
293 set_default_path (void) |
|
294 { |
3192
|
295 Vdefault_load_path = subst_octave_home (OCTAVE_FCNFILEPATH); |
2203
|
296 |
3523
|
297 std::string oct_path = octave_env::getenv ("OCTAVE_PATH"); |
2203
|
298 |
5777
|
299 Vload_path = oct_path.empty () ? dir_path::path_sep_str : oct_path; |
3174
|
300 |
4217
|
301 update_load_path_dir_path (); |
2203
|
302 } |
|
303 |
|
304 static void |
|
305 set_default_info_file (void) |
|
306 { |
3523
|
307 std::string std_info_file = subst_octave_home (OCTAVE_INFOFILE); |
2512
|
308 |
3523
|
309 std::string oct_info_file = octave_env::getenv ("OCTAVE_INFO_FILE"); |
2203
|
310 |
2926
|
311 Vinfo_file = oct_info_file.empty () ? std_info_file : oct_info_file; |
2203
|
312 } |
|
313 |
|
314 static void |
|
315 set_default_info_prog (void) |
|
316 { |
3523
|
317 std::string oct_info_prog = octave_env::getenv ("OCTAVE_INFO_PROGRAM"); |
2203
|
318 |
2926
|
319 if (oct_info_prog.empty ()) |
3141
|
320 Vinfo_prog = "info"; |
2926
|
321 else |
3523
|
322 Vinfo_prog = std::string (oct_info_prog); |
2203
|
323 } |
|
324 |
4773
|
325 static void |
4776
|
326 set_default_fftw_wisdom_prog (void) |
4773
|
327 { |
4776
|
328 std::string oct_wisdom_prog = octave_env::getenv ("OCTAVE_FFTW_WISDOM_PROGRAM"); |
4773
|
329 |
|
330 if (oct_wisdom_prog.empty ()) |
4776
|
331 Vfftw_wisdom_prog = "fftw-wisdom"; |
4773
|
332 else |
4776
|
333 Vfftw_wisdom_prog = std::string (oct_wisdom_prog); |
4773
|
334 } |
|
335 |
2203
|
336 static void |
|
337 set_default_editor (void) |
|
338 { |
2993
|
339 Veditor = "emacs"; |
2203
|
340 |
3523
|
341 std::string env_editor = octave_env::getenv ("EDITOR"); |
2203
|
342 |
2926
|
343 if (! env_editor.empty ()) |
|
344 Veditor = env_editor; |
2203
|
345 } |
|
346 |
|
347 static void |
|
348 set_local_site_defaults_file (void) |
|
349 { |
|
350 Vlocal_site_defaults_file = subst_octave_home (OCTAVE_LOCALSTARTUPFILEDIR); |
|
351 Vlocal_site_defaults_file.append ("/octaverc"); |
|
352 } |
|
353 |
|
354 static void |
|
355 set_site_defaults_file (void) |
|
356 { |
|
357 Vsite_defaults_file = subst_octave_home (OCTAVE_STARTUPFILEDIR); |
|
358 Vsite_defaults_file.append ("/octaverc"); |
|
359 } |
|
360 |
3534
|
361 std::string |
3523
|
362 maybe_add_default_load_path (const std::string& pathstring) |
2203
|
363 { |
3523
|
364 std::string retval; |
2203
|
365 |
|
366 if (! pathstring.empty ()) |
|
367 { |
5777
|
368 if (dir_path::is_path_sep (pathstring[0])) |
2203
|
369 { |
3192
|
370 retval = Vdefault_load_path; |
2203
|
371 retval.append (pathstring); |
|
372 } |
|
373 else |
|
374 retval = pathstring; |
|
375 |
5777
|
376 if (dir_path::is_path_sep (pathstring[pathstring.length () - 1])) |
3192
|
377 retval.append (Vdefault_load_path); |
|
378 |
|
379 size_t pos = 0; |
|
380 do |
|
381 { |
5777
|
382 pos = retval.find (dir_path::path_sep_str + dir_path::path_sep_str); |
3192
|
383 |
|
384 if (pos != NPOS) |
|
385 retval.insert (pos+1, Vdefault_load_path); |
|
386 } |
|
387 while (pos != NPOS); |
2203
|
388 } |
|
389 |
|
390 return retval; |
|
391 } |
|
392 |
|
393 void |
|
394 install_defaults (void) |
|
395 { |
|
396 // OCTAVE_HOME must be set first! |
|
397 |
|
398 set_octave_home (); |
|
399 |
|
400 set_default_info_dir (); |
|
401 |
3141
|
402 set_default_data_dir (); |
|
403 |
|
404 set_default_libexec_dir (); |
|
405 |
2203
|
406 set_default_arch_lib_dir (); |
|
407 |
2439
|
408 set_default_local_arch_lib_dir (); |
|
409 |
3597
|
410 set_default_local_ver_arch_lib_dir (); |
|
411 |
2203
|
412 set_default_fcn_file_dir (); |
|
413 |
5397
|
414 set_default_oct_file_dir (); |
|
415 |
2203
|
416 set_default_bin_dir (); |
|
417 |
4447
|
418 set_default_default_exec_path (); |
|
419 |
2203
|
420 set_default_exec_path (); |
|
421 |
|
422 set_default_path (); |
|
423 |
|
424 set_default_info_file (); |
|
425 |
|
426 set_default_info_prog (); |
|
427 |
4776
|
428 set_default_fftw_wisdom_prog (); |
4773
|
429 |
2203
|
430 set_default_editor (); |
|
431 |
|
432 set_local_site_defaults_file (); |
|
433 |
|
434 set_site_defaults_file (); |
|
435 } |
|
436 |
4264
|
437 DEFUN (rehash, , , |
|
438 "-*- texinfo -*-\n\ |
|
439 @deftypefn {Built-in Function} {} rehash ()\n\ |
|
440 Reinitialize Octave's @code{LOADPATH} directory cache.\n\ |
|
441 @end deftypefn") |
|
442 { |
|
443 octave_value_list retval; |
|
444 |
|
445 Vload_path_dir_path.rehash (); |
|
446 |
|
447 return retval; |
|
448 } |
|
449 |
2203
|
450 static int |
|
451 editor (void) |
|
452 { |
|
453 int status = 0; |
|
454 |
3523
|
455 std::string s = builtin_string_variable ("EDITOR"); |
2203
|
456 |
|
457 if (s.empty ()) |
|
458 { |
|
459 gripe_invalid_value_specified ("EDITOR"); |
|
460 status = -1; |
|
461 } |
|
462 else |
|
463 Veditor = s; |
|
464 |
|
465 return status; |
|
466 } |
|
467 |
|
468 static int |
|
469 exec_path (void) |
|
470 { |
|
471 int status = 0; |
|
472 |
3523
|
473 std::string s = builtin_string_variable ("EXEC_PATH"); |
2439
|
474 |
|
475 if (s.empty ()) |
2203
|
476 { |
|
477 gripe_invalid_value_specified ("EXEC_PATH"); |
|
478 status = -1; |
|
479 } |
|
480 else |
|
481 { |
2439
|
482 Vexec_path = s; |
|
483 |
3523
|
484 std::string path; |
2203
|
485 |
|
486 int eplen = Vexec_path.length (); |
|
487 |
|
488 if (eplen > 0) |
|
489 { |
2926
|
490 bool prepend = (Vexec_path[0] == ':'); |
|
491 bool append = (eplen > 1 && Vexec_path[eplen-1] == ':'); |
2203
|
492 |
|
493 if (prepend) |
|
494 { |
4447
|
495 path = Vdefault_exec_path + Vexec_path; |
2203
|
496 } |
|
497 else |
|
498 { |
2926
|
499 path = Vexec_path; |
|
500 |
2203
|
501 if (append) |
4447
|
502 path.append (Vdefault_exec_path); |
2203
|
503 } |
|
504 } |
|
505 else |
4447
|
506 path = Vdefault_exec_path; |
2203
|
507 |
2926
|
508 octave_env::putenv ("PATH", path); |
2203
|
509 } |
|
510 |
|
511 return status; |
|
512 } |
|
513 |
4773
|
514 static int |
4776
|
515 fftw_wisdom_prog (void) |
4773
|
516 { |
|
517 int status = 0; |
|
518 |
4776
|
519 std::string s = builtin_string_variable ("FFTW_WISDOM_PROGRAM"); |
4773
|
520 |
|
521 if (s.empty ()) |
|
522 { |
4776
|
523 gripe_invalid_value_specified ("FFTW_WISDOM_PROGRAM"); |
4773
|
524 status = -1; |
|
525 } |
|
526 else |
4776
|
527 Vfftw_wisdom_prog = s; |
4773
|
528 |
|
529 return status; |
|
530 } |
|
531 |
2203
|
532 static int |
4447
|
533 default_exec_path (void) |
|
534 { |
|
535 int status = 0; |
|
536 |
|
537 std::string s = builtin_string_variable ("DEFAULT_EXEC_PATH"); |
|
538 |
|
539 if (s.empty ()) |
|
540 { |
|
541 gripe_invalid_value_specified ("DEFAULT_EXEC_PATH"); |
|
542 status = -1; |
|
543 } |
|
544 else |
|
545 { |
|
546 Vdefault_exec_path = s; |
|
547 |
|
548 // Now also update PATH in environment. |
|
549 exec_path (); |
|
550 } |
|
551 |
|
552 return status; |
|
553 } |
|
554 |
|
555 static int |
2203
|
556 imagepath (void) |
|
557 { |
|
558 int status = 0; |
|
559 |
3523
|
560 std::string s = builtin_string_variable ("IMAGEPATH"); |
2203
|
561 |
|
562 if (s.empty ()) |
|
563 { |
|
564 gripe_invalid_value_specified ("IMAGEPATH"); |
|
565 status = -1; |
|
566 } |
|
567 else |
|
568 Vimagepath = s; |
|
569 |
|
570 return status; |
|
571 } |
|
572 |
|
573 static int |
|
574 loadpath (void) |
|
575 { |
|
576 int status = 0; |
|
577 |
3523
|
578 std::string s = builtin_string_variable ("LOADPATH"); |
2203
|
579 |
|
580 if (s.empty ()) |
|
581 { |
|
582 gripe_invalid_value_specified ("LOADPATH"); |
|
583 status = -1; |
|
584 } |
5395
|
585 else if (Vload_path != s) |
3174
|
586 { |
3971
|
587 // I'm not sure whether this causes more problems that it |
|
588 // solves... |
|
589 // if (! (s[0] == ':' || s[s.length () - 1] == ':' |
5777
|
590 // || s.find (dir_path::path_sep_str + |
|
591 // dir_path::path_sep_str) != NPOS)) |
3971
|
592 // warning ("LOADPATH will ignore default load path"); |
3967
|
593 |
3195
|
594 Vload_path = s; |
3174
|
595 |
5395
|
596 // By resetting the last prompt time variable, we will force |
|
597 // checks for out of date symbols even if the change to LOADPATH |
|
598 // and subsequent function calls happen between prompts. |
|
599 |
5775
|
600 // FIXME -- maybe we should rename |
5395
|
601 // Vlast_prompt_time_stamp since the new usage doesn't really |
|
602 // fit with the current name? |
|
603 |
|
604 Vlast_prompt_time.stamp (); |
|
605 |
4217
|
606 update_load_path_dir_path (); |
|
607 } |
|
608 |
|
609 return status; |
|
610 } |
|
611 |
|
612 static int |
|
613 default_load_path (void) |
|
614 { |
|
615 int status = 0; |
|
616 |
|
617 std::string s = builtin_string_variable ("DEFAULT_LOADPATH"); |
|
618 |
|
619 if (s.empty ()) |
|
620 { |
|
621 gripe_invalid_value_specified ("DEFAULT_LOADPATH"); |
|
622 status = -1; |
|
623 } |
|
624 else |
|
625 { |
|
626 Vdefault_load_path = s; |
|
627 |
|
628 update_load_path_dir_path (); |
3174
|
629 } |
2203
|
630 |
|
631 return status; |
|
632 } |
|
633 |
|
634 void |
|
635 symbols_of_defaults (void) |
|
636 { |
3258
|
637 DEFVAR (EDITOR, Veditor, editor, |
3368
|
638 "-*- texinfo -*-\n\ |
|
639 @defvr {Built-in Variable} EDITOR\n\ |
|
640 A string naming the editor to use with the @code{edit_history} command.\n\ |
|
641 If the environment variable @code{EDITOR} is set when Octave starts, its\n\ |
|
642 value is used as the default. Otherwise, @code{EDITOR} is set to\n\ |
|
643 @code{\"emacs\"}.\n\ |
|
644 @end defvr"); |
2203
|
645 |
4776
|
646 DEFVAR (FFTW_WISDOM_PROGRAM, Vfftw_wisdom_prog, fftw_wisdom_prog, |
4773
|
647 "-*- texinfo -*-\n\ |
4776
|
648 @defvr {Built-in Variable} FFTW_WISDOM_PROGRAM\n\ |
4773
|
649 A string naming the FFTW wisdom program to use to create wisdom data\n\ |
|
650 to accelerate Fourier transforms. If the environment variable\n\ |
|
651 @code{OCTAVE_WISDOM_PROGRAM} is set when Octave starts, its value is used\n\ |
|
652 as the default. Otherwise, @code{WISDOM_PROGRAM} is set to\n\ |
|
653 @code{\"fftw-wisdom\"}.\n\ |
|
654 @end defvr"); |
|
655 |
3258
|
656 DEFVAR (EXEC_PATH, Vexec_path, exec_path, |
3301
|
657 "-*- texinfo -*-\n\ |
|
658 @defvr {Built-in Variable} EXEC_PATH\n\ |
|
659 The variable @code{EXEC_PATH} is a colon separated list of directories\n\ |
4447
|
660 to search when executing external programs. Its initial value is taken from\n\ |
3301
|
661 the environment variable @code{OCTAVE_EXEC_PATH} (if it exists) or\n\ |
|
662 @code{PATH}, but that value can be overridden by the command line\n\ |
|
663 argument @code{--exec-path PATH}, or by setting the value of\n\ |
|
664 @code{EXEC_PATH} in a startup script. If the value of @code{EXEC_PATH}\n\ |
|
665 begins (ends) with a colon, the directories\n\ |
|
666 \n\ |
|
667 @example\n\ |
|
668 @group\n\ |
|
669 @var{octave-home}/libexec/octave/site/exec/@var{arch}\n\ |
|
670 @var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}\n\ |
|
671 @end group\n\ |
|
672 @end example\n\ |
|
673 \n\ |
|
674 @noindent\n\ |
|
675 are prepended (appended) to @code{EXEC_PATH}, where @var{octave-home}\n\ |
|
676 is the top-level directory where all of Octave is installed\n\ |
|
677 (the default value is @file{@value{OCTAVEHOME}}). If you don't specify\n\ |
|
678 a value for @code{EXEC_PATH} explicitly, these special directories are\n\ |
|
679 prepended to your shell path.\n\ |
|
680 @end defvr"); |
2203
|
681 |
4447
|
682 DEFVAR (DEFAULT_EXEC_PATH, Vdefault_exec_path, default_exec_path, |
|
683 "-*- texinfo -*-\n\ |
|
684 @defvr {Built-in Variable} DEFAULT_EXEC_PATH\n\ |
|
685 A colon separated list of directories in which to search when executing\n\ |
|
686 external programs. The value of this variable is automatically\n\ |
|
687 substituted for leading, trailing, or doubled colons that appear in the\n\ |
|
688 built-in variable @code{EXEC_PATH}.\n\ |
|
689 @end defvr"); |
4773
|
690 |
3258
|
691 DEFVAR (LOADPATH, Vload_path, loadpath, |
3371
|
692 "-*- texinfo -*-\n\ |
|
693 @defvr {Built-in Variable} LOADPATH\n\ |
|
694 A colon separated list of directories in which to search for function\n\ |
|
695 files. @xref{Functions and Scripts}. The value of @code{LOADPATH}\n\ |
|
696 overrides the environment variable @code{OCTAVE_PATH}. @xref{Installation}.\n\ |
|
697 \n\ |
|
698 @code{LOADPATH} is now handled in the same way as @TeX{} handles\n\ |
|
699 @code{TEXINPUTS}. Leading, trailing, or doubled colons that appear in\n\ |
|
700 @code{LOADPATH} are replaced by the value of @code{DEFAULT_LOADPATH}.\n\ |
5451
|
701 The default value of @code{LOADPATH} is @code{\"\n" |
|
702 SEPCHAR_STR |
|
703 "\"}, which tells Octave to search in the directories specified by\n\ |
|
704 @code{DEFAULT_LOADPATH}.\n\ |
3371
|
705 \n\ |
|
706 In addition, if any path element ends in @samp{//}, that directory and\n\ |
|
707 all subdirectories it contains are searched recursively for function\n\ |
|
708 files. This can result in a slight delay as Octave caches the lists of\n\ |
|
709 files found in the @code{LOADPATH} the first time Octave searches for a\n\ |
|
710 function. After that, searching is usually much faster because Octave\n\ |
|
711 normally only needs to search its internal cache for files.\n\ |
|
712 \n\ |
|
713 To improve performance of recursive directory searching, it is best for\n\ |
|
714 each directory that is to be searched recursively to contain\n\ |
|
715 @emph{either} additional subdirectories @emph{or} function files, but\n\ |
|
716 not a mixture of both.\n\ |
|
717 \n\ |
3402
|
718 @xref{Organization of Functions}, for a description of the function file\n\ |
3371
|
719 directories that are distributed with Octave.\n\ |
|
720 @end defvr"); |
2203
|
721 |
4217
|
722 DEFVAR (DEFAULT_LOADPATH, Vdefault_load_path, default_load_path, |
3371
|
723 "-*- texinfo -*-\n\ |
|
724 @defvr {Built-in Variable} DEFAULT_LOADPATH\n\ |
|
725 A colon separated list of directories in which to search for function\n\ |
4447
|
726 files. The value of this variable is automatically substituted for\n\ |
|
727 leading, trailing, or doubled colons that appear in the built-in\n\ |
|
728 variable @code{LOADPATH}.\n\ |
3371
|
729 @end defvr"); |
3192
|
730 |
3258
|
731 DEFVAR (IMAGEPATH, OCTAVE_IMAGEPATH, imagepath, |
3373
|
732 "-*- texinfo -*-\n\ |
3532
|
733 @defvr {Built-in Variable} IMAGEPATH\n\ |
3373
|
734 A colon separated list of directories in which to search for image\n\ |
|
735 files.\n\ |
|
736 @end defvr"); |
5780
|
737 } |
2203
|
738 |
5780
|
739 DEFUN (OCTAVE_HOME, args, , |
|
740 "-*- texinfo -*-\n\ |
|
741 @deftypefn {Built-in Function} {} OCTAVE_HOME ()\n\ |
|
742 Return the name of the top-level Octave installation directory.\n\ |
|
743 @end deftypefn") |
|
744 { |
|
745 octave_value retval; |
2831
|
746 |
5780
|
747 if (args.length () == 0) |
|
748 retval = Voctave_home; |
|
749 else |
|
750 print_usage ("OCTAVE_HOME"); |
|
751 |
|
752 return retval; |
5749
|
753 } |
3446
|
754 |
5749
|
755 DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , |
|
756 "-*- texinfo -*-\n\ |
|
757 @deftypefn {Built-in Function} {} OCTAVE_VERSION ()\n\ |
|
758 Return the version number of Octave, as a string.\n\ |
|
759 @end deftypefn") |
|
760 { |
|
761 octave_value retval; |
|
762 |
|
763 int nargin = args.length (); |
|
764 |
|
765 if (nargin == 0) |
|
766 retval = OCTAVE_VERSION; |
|
767 else |
|
768 print_usage ("OCTAVE_VERSION"); |
|
769 |
|
770 return retval; |
2203
|
771 } |
|
772 |
|
773 /* |
|
774 ;;; Local Variables: *** |
|
775 ;;; mode: C++ *** |
|
776 ;;; End: *** |
|
777 */ |