bugGNU Octave - Bugs: bug #44694, prefdir returns a blank result on...

 
 

bug #44694: prefdir returns a blank result on Windows 8

Submitter:  Michael C. Grant <mcgrant>
Submitted:  Wed 01 Apr 2015 09:22:28 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 02 Jun 2015 04:43:12 PM UTC, comment #10: 

Retagging release from 4.0.0-rc2 to 4.0.0.

John W. Eaton <jwe>
Group administrator
Thu 02 Apr 2015 09:20:03 PM UTC, comment #9: 

@rik:  Hmm, I don't know.  I guess we should add it to the manual since it is better than using getenv ("HOME").

John W. Eaton <jwe>
Group administrator
Thu 02 Apr 2015 08:41:57 PM UTC, comment #8: 

Great, thanks for the updates. I'm afraid I can't compile the Windows version locally so I'll have wait for the next release. But I'm in good shape now regardless.

Michael C. Grant <mcgrant>
Thu 02 Apr 2015 05:44:39 PM UTC, comment #7: 

Should get_home_directory be an internal or external function?  If it is meant to be used widely then a DOCSTRING entry should be added to the Octave manual and a note added to the new functions section of the NEWS file.

Rik <rik5>
Group administrator
Thu 02 Apr 2015 05:30:13 PM UTC, comment #6: 
John W. Eaton <jwe>
Group administrator
Thu 02 Apr 2015 12:13:26 PM UTC, comment #5: 

I'm not sure it is necessary to guard against that case. I can't think of any practical use for changing those particular variables (in the very least because they are meaningless in UNIX).

That said, "getenv('HOME')" returns the empty string on Windows in MATLAB, too. So this is not a compatibility issue.

I think it is reasonable for the fix to be specific to the "prefdir" command. In my code I've decided to fall back on "tilde_expand" if "prefdir" returns an empty result.

Michael C. Grant <mcgrant>
Thu 02 Apr 2015 11:24:18 AM UTC, comment #4: 

It occurs to me that simply exporting HOME = HOMEDRIVE + HOMEPATH once when Octave starts won't do the right thing if someone sets the HOMEDRIVE or HOMEPATH environment variables in an Octave program and expects those to change Octave's behavior.  So rather than expecting getenv ("HOME") to work, I guess the correct thing is to provide a system dependent function that returns the home directory location and use that consistently instead of getenv.

John W. Eaton <jwe>
Group administrator
Wed 01 Apr 2015 10:18:44 PM UTC, comment #3: 

I think it will be easier to export a HOME variable, rather than changing what is a straightforward assumption about UNIX platforms.  It might be better to do it in the executable, howeve, in case people call it directly rather than through the desktop shortcuts.

Rik <rik5>
Group administrator
Wed 01 Apr 2015 09:45:08 PM UTC, comment #2: 

It looks like


tilde_expand ("~")


should return HOMEDRIVE + HOMEPATH on Windows systems so maybe we should use tilde_expand instead of getenv ("HOME")?

We may also want to export HOME = HOMEDRIVE + HOMEPATH in the octave.vbs wrapper script since I suspect there is other code out there that expects to be able to do getenv ("HOME")...

John W. Eaton <jwe>
Group administrator
Wed 01 Apr 2015 09:40:21 PM UTC, comment #1: 

Correction: HOMEPATH is not enough; we need to use [HOMEDRIVE,HOMEPATH].

Michael C. Grant <mcgrant>
Wed 01 Apr 2015 09:22:28 PM UTC, original submission:  

prefdir is defined rather simply: it returns the value of HOME environment variable.


function folder = prefdir ()
  folder = getenv ("HOME");
endfunction


This is  just fine on Unix-based systems. However, on my rather vanilla installation of Windows 8.1, the HOME variable is not defined, so this function returns the empty string.

The closest I can come to for HOME is HOMEPATH. LOCALAPPDATA may be a better environment variable to use for prefdir anyway, although in that case you would want to make sure that the directory is created when requested.

Michael C. Grant <mcgrant>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mcgrant (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-02 jwe Release4.0.0-rc2 4.0.0
    2015-04-04 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-04-02 rik5 StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code