windows native Octave-2.9.9+ does not read ./.octaverc at startup
Bill Denney
bill at denney.ws
Wed Jun 25 07:44:29 CDT 2008
Kenneth Cate wrote:
> Benjamin Lindner wrote:
>
>> I have installed michael's Octave 2.9.9+ windows binary from
>> http://www.dbateman.org/?page=octave&lang=EN and found, that at
>> startup octave does not load a .octaverc file in the current directory.
>> The startup file in the home directory and the system-wide startup files
>> are loaded.
>> I do not see this behaviour with version 2.9.9 under linux&cygwin and
>> neither with 2.9.10 under cygwin, so i guess this is a bug in the windows
>> port?
>
> A possible way to get around the problem in Windows is to patch the script
> "c:\Program Files\Octave\share\octave\version\m\startup\octaverc".
> I added to my copy of octaverc the following:
>
> # Execute the current User's startup.m and .octaverc on a Windows System
> # ( Added by Kenneth H. Cate on 2008-06-19 )
> #
> users_path = getenv("USERPROFILE");
> if ~isempty(users_path)
> users_path = [users_path, filesep];
>
> # Windows:
> p1 = [users_path, "Application Data", filesep, "octave"]; # Some users
> might prefer this path
> p2 = [p1, filesep];
> if (exist ([p2, "startup.m"], "file")), addpath (p1, "-end");
> elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end
>
> # Windows Vista:
> p1 = [users_path, "AppData", filesep, "Roaming", filesep, "octave"];
> p2 = [p1, filesep];
> if (exist ([p2, "startup.m"], "file")), addpath (p1, "-end");
> elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end
>
> p1 = [users_path, "octave"];
> p2 = [p1, filesep];
> if (exist ([p2, "startup.m"], "file")); addpath (p1, "-end");
> elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end
> if (exist ("startup.m", "file"))
> startup
> end
> clear p1 p2
> end
> clear users_path
>
> This goes ahead of the final fprintf ("\n")
> This allows Octave to find the startup.m or .octaverc scripts for the
> current user.
>
Hi Kenneth,
A simpler version would be (using the APPDATA environmental variable,
fullfile, and source):
# Execute the current User's .octaverc or startup.m on a Windows System
# ( Added by Kenneth H. Cate on 2008-06-19 )
#
users_path = getenv ("APPDATA");
if ~isempty (users_path)
## Some users might prefer this path
users_path = fullfile (users_path, "octave");
if exist (fullfile (users_path, ".octaverc"), "file")
source (fullfile (users_path, ".octaverc"));
elseif exist (fullfile (users_path, "startup.m"), "file")
source (fullfile (users_path, "startup.m"));
endif
end
clear users_path
Have a good day,
Bill
More information about the Bug-octave
mailing list