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

 
 

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

Submitted by:  Michael C. Grant <mcgrant>
Submitted on:  Wed 01 Apr 2015 09:22:28 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.0.0Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project 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>
Project Administrator
Thu 02 Apr 2015 05:30:13 PM UTC, comment #6:

I checked in the following changesets:

http://hg.savannah.gnu.org/hgweb/octave/rev/47d420d769ba
http://hg.savannah.gnu.org/hgweb/octave/rev/4b7b7ac7af2c

John W. Eaton <jwe>
Project 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>
Project 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>
Project Administrator
Wed 01 Apr 2015 09:45:08 PM UTC, comment #2:

It looks like

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>
Project 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.

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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 02 Jun 2015 04:43:12 PM UTCjweRelease4.0.0-rc2=>4.0.0
    Sat 04 Apr 2015 04:14:29 PM UTCrik5StatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Thu 02 Apr 2015 05:44:39 PM UTCrik5StatusNone=>Ready For Test

    Back to the top


    Powered by Savane 3.1-cleanup1