39 #include <sys/types.h>
193 octave_argv.
resize (argc - 1);
198 octave_argv[i-1] = *(argv+i);
202 DEFUN (__version_info__, args, ,
204 @deftypefn {Built-in Function} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\
205 Undocumented internal function.\n\
212 int nargin = args.
length ();
218 vinfo.
assign (
"Name", args (0));
219 vinfo.
assign (
"Version", args (1));
220 vinfo.
assign (
"Release", args (2));
221 vinfo.
assign (
"Date", args (3));
237 else if (nargin == 0)
253 args(0) =
"GNU Octave";
261 std::cerr <<
"error: " << msg <<
"\n"
262 <<
"error: execution of " << file <<
" failed\n"
263 <<
"error: trying to make my way to a command prompt"
274 const std::string&
context = std::string (),
275 bool verbose =
false,
bool require_file =
true,
276 const std::string& warn_for = std::string ())
282 catch (octave_interrupt_exception)
289 catch (octave_execution_exception)
307 bool require_file =
false;
328 bool home_rc_already_executed =
false;
332 if (initfile.empty ())
333 initfile =
".octaverc";
339 std::string local_rc;
341 if (! home_rc.empty ())
356 home_rc_already_executed =
same_file (home_rc, local_rc);
360 if (! home_rc_already_executed)
362 if (local_rc.empty ())
391 int parse_status = 0;
397 catch (octave_interrupt_exception)
404 catch (octave_execution_exception)
407 std::cerr <<
"error: unhandled execution exception -- eval failed"
443 = (pos != std::string::npos) ? fname.substr (pos+1) : fname;
446 bool verbose =
false;
447 bool require_file =
true;
456 va_start (args, fmt);
467 va_start (args, fmt);
532 octave_cmdline_argc = argc;
533 octave_cmdline_argv = argv;
585 command_line_path.push_back (optarg);
705 error (
"only one of --force-gui and --no-gui may be used");
710 bool script_file = (argc - optind) > 0;
713 error (
"--eval \"CODE\" and script file are mutually exclusive options");
728 setlocale (LC_NUMERIC,
"C");
729 setlocale (LC_TIME,
"C");
733 octave_embedded = embedded;
780 for (std::list<std::string>::const_iterator it = command_line_path.begin ();
781 it != command_line_path.end (); it++)
797 bool stdin_is_tty = gnulib::isatty (fileno (stdin));
800 && gnulib::isatty (fileno (stdout)));
854 std::cout << std::endl;
872 int last_arg_idx = optind;
873 int remaining_args = octave_cmdline_argc - last_arg_idx;
875 if (remaining_args > 0)
880 intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx);
897 intern_argv (octave_cmdline_argc, octave_cmdline_argv);
957 if (! gnulib::isatty (fileno (stdin)))
963 int last_arg_idx = optind;
964 int remaining_args = octave_cmdline_argc - last_arg_idx;
981 DEFUN (isguirunning, args, ,
983 @deftypefn {Built-in Function} {} isguirunning ()\n\
984 Return true if Octave is running in GUI mode and false otherwise.\n\
985 @seealso{have_window_system}\n\
990 if (args.length () == 0)
1003 DEFUN (argv, args, ,
1005 @deftypefn {Built-in Function} {} argv ()\n\
1006 Return the command line arguments passed to Octave.\n\
1008 For example, if you invoked Octave using the command\n\
1011 octave --no-line-editing --silent\n\
1015 @code{argv} would return a cell array of strings with the elements\n\
1016 @option{--no-line-editing} and @option{--silent}.\n\
1018 If you write an executable Octave script, @code{argv} will return the list\n\
1019 of arguments passed to the script. @xref{Executable Octave Programs}, for\n\
1020 an example of how to create an executable Octave script.\n\
1025 if (args.length () == 0)
1026 retval =
Cell (octave_argv);
1038 DEFUN (program_invocation_name, args, ,
1040 @deftypefn {Built-in Function} {} program_invocation_name ()\n\
1041 Return the name that was typed at the shell prompt to run Octave.\n\
1043 If executing a script from the command line (e.g., @code{octave foo.m})\n\
1044 or using an executable Octave script, the program name is set to the\n\
1045 name of the script. @xref{Executable Octave Programs}, for an example of\n\
1046 how to create an executable Octave script.\n\
1047 @seealso{program_name}\n\
1052 if (args.length () == 0)
1065 DEFUN (program_name, args, ,
1067 @deftypefn {Built-in Function} {} program_name ()\n\
1068 Return the last component of the value returned by\n\
1069 @code{program_invocation_name}.\n\
1070 @seealso{program_invocation_name}\n\
1075 if (args.length () == 0)
#define LINE_EDITING_OPTION
void warning_with_id(const char *id, const char *fmt,...)
void set_exec_path(const std::string &path_arg)
static bool force_gui_option
std::string Vsite_defaults_file
#define F77_CHAR_ARG_LEN(l)
int octave_execute_interpreter(void)
void install_classdef(void)
static std::string octave_program_invocation_name
static void mark_hidden(const std::string &name)
subroutine xerbla(SRNAME, INFO)
bool same_file(const std::string &f, const std::string &g)
static std::string get_program_name(void)
void(* octave_interrupt_hook)(void)=0
static bool at_top_level(void)
OCTINTERP_API octave_value_list Fhistory_save(const octave_value_list &=octave_value_list(), int=0)
static void octave_print_version_and_exit(void)
std::string octave_startup_message(bool html)
void assign(const std::string &k, const Cell &val)
OCTINTERP_API octave_value_list Finfo_program(const octave_value_list &=octave_value_list(), int=0)
void octave_prepare_hdf5(void)
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file, const std::string &warn_for)
static string_vector octave_argv
static bool inhibit_startup_message
void recover_from_exception(void)
OCTINTERP_API octave_value_list Fdisable_diagonal_matrix(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API void print_usage(void)
void octave_save_signal_mask(void)
OCTINTERP_API octave_value_list Fjit_enable(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API octave_value_list FPS1(const octave_value_list &=octave_value_list(), int=0)
static void putenv(const std::string &name, const std::string &value)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DECL
static void reset_current_command_number(int n)
OCTINTERP_API octave_value_list Fconfirm_recursive_rmdir(const octave_value_list &=octave_value_list(), int=0)
static void initialize_version_info(void)
static void lo_error_with_id_handler(const char *id, const char *fmt,...)
#define DEFUN(name, args_name, nargout_name, doc)
OCTINTERP_API octave_value_list FPS4(const octave_value_list &=octave_value_list(), int=0)
void error(const char *fmt,...)
octave_interrupt_handler octave_catch_interrupts(void)
static void execute_startup_files(void)
void(* octave_bad_alloc_hook)(void)=0
static void initialize_error_handlers()
static bool an_octave_program
static void set_program_name(const std::string &s)
static void set_command_line_path(const std::string &p)
void set_image_path(const std::string &path)
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
OCTINTERP_API octave_value_list Fpage_screen_output(const octave_value_list &=octave_value_list(), int=0)
octave_idx_type numel(void) const
#define IMAGE_PATH_OPTION
OCTINTERP_API octave_value_list Fdebug_jit(const octave_value_list &=octave_value_list(), int=0)
static void intern_argv(int argc, char **argv)
#define NO_SITE_FILE_OPTION
int octave_main(int argc, char **argv, int embedded)
OCTINTERP_API octave_value_list Fbeep_on_error(const octave_value_list &=octave_value_list(), int=0)
static bool no_window_system
int octave_starting_gui(void)
#define TRADITIONAL_OPTION
#define NO_LINE_EDITING_OPTION
static void gripe_safe_source_exception(const std::string &file, const std::string &msg)
OCTINTERP_API octave_value_list Ftexi_macros_file(const octave_value_list &=octave_value_list(), int=0)
struct option long_opts[]
void octave_ieee_init(void)
OCTINTERP_API octave_value_list Fdisable_range(const octave_value_list &=octave_value_list(), int=0)
char ** octave_cmdline_argv
#define TEXI_MACROS_FILE_OPTION
void initialize_history(bool read_history_file)
void set_liboctave_warning_with_id_handler(liboctave_warning_with_id_handler f)
static std::string exec_path
void octave_initialize_interpreter(int argc, char **argv, int embedded)
#define OCTAVE_RELEASE_DATE
OCTINTERP_API octave_value_list Fdisable_permutation_matrix(const octave_value_list &=octave_value_list(), int=0)
static std::string code_to_eval
static std::string get_program_invocation_name(void)
static std::list< std::string > command_line_path
void verror_with_cfn(const char *fmt, va_list args)
OCTINTERP_API octave_value_list Fhistory_timestamp_format_string(const octave_value_list &=octave_value_list(), int=0)
static void octave_print_terse_usage_and_exit(void)
void install_signal_handlers(void)
void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
static bool read_site_files
void octave_throw_execution_exception(void)
static void maximum_braindamage(void)
OCTINTERP_API octave_value_list Fcrash_dumps_octave_core(const octave_value_list &=octave_value_list(), int=0)
octave_idx_type nfields(void) const
static llvm::LLVMContext & context
OCTINTERP_API octave_value_list Fecho_executing_commands(const octave_value_list &=octave_value_list(), int=0)
static bool no_gui_option
void resize(octave_idx_type n, const std::string &rfv=std::string())
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
static void lo_error_handler(const char *fmt,...)
static int execute_eval_option_code(const std::string &code)
OCTAVE_EXPORT octave_value_list F__version_info__(const octave_value_list &args, int)
void set_liboctave_error_handler(liboctave_error_handler f)
void octave_process_command_line(int argc, char **argv)
static std::string getenv(const std::string &name)
static void initialize(bool set_initial_path=false)
F77_RET_T const octave_idx_type & F77_CHAR_ARG_LEN_DECL
OCTINTERP_API octave_value_list Fsave_default_options(const octave_value_list &=octave_value_list(), int=0)
void initialize_default_warning_state(void)
void set_liboctave_warning_handler(liboctave_warning_handler f)
void set_liboctave_error_with_id_handler(liboctave_error_with_id_handler f)
#define panic_impossible()
void clean_up_and_exit(int status, bool safe_to_return)
std::string Vlocal_site_defaults_file
static void assign(const std::string &name, const octave_value &value=octave_value(), scope_id scope=xcurrent_scope, context_id context=xdefault_context, bool force_add=false)
OCTINTERP_API octave_value_list Fprint_empty_dimensions(const octave_value_list &=octave_value_list(), int=0)
void octave_signal_handler(void)
void disable_warning(const std::string &id)
void warning(const char *fmt,...)
static std::string dir_sep_chars(void)
static std::string octave_program_name
void(* octave_signal_hook)(void)=0
static bool set_initial_path
static void no_window_system(void)
#define F77_CONST_CHAR_ARG_DECL
static const char * short_opts
static void force_default_editor(void)
static bool display_available(void)
std::list< octave_value_list > idx
#define DOC_CACHE_FILE_OPTION
static bool forced_line_editing
#define BUILT_IN_DOCSTRINGS_FILE_OPTION
octave_idx_type length(void) const
static void octave_print_verbose_usage_and_exit(void)
static bool read_init_files
OCTINTERP_API octave_value_list Finfo_file(const octave_value_list &=octave_value_list(), int=0)
static void safe_source_file(const std::string &file_name, const std::string &context=std::string(), bool verbose=false, bool require_file=true, const std::string &warn_for=std::string())
void resize(const dim_vector &dv, bool fill=false)
OCTINTERP_API octave_value_list Ffixed_point_format(const octave_value_list &=octave_value_list(), int=0)
void initialize_file_io(void)
static void blink_matching_paren(bool flag)
#define NO_INIT_PATH_OPTION
void install_defaults(void)
#define NO_INIT_FILE_OPTION
static void execute_command_line_file(const std::string &fname)
OCTINTERP_API octave_value_list FPS2(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API octave_value_list Fbuilt_in_docstrings_file(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API octave_value_list Fdoc_cache_file(const octave_value_list &=octave_value_list(), int=0)
bool reading_startup_message_printed
void install_builtins(void)
bool octave_interpreter_ready
static std::string image_path
#define JIT_COMPILER_OPTION
static bool check_starting_gui(void)
static bool read_history_file
OCTINTERP_API octave_value_list Fstruct_levels_to_print(const octave_value_list &=octave_value_list(), int=0)
static std::string get_home_directory(void)