bugGNU Octave - Bugs: bug #40726, <Tab> complete uses...

 
 

bug #40726: <Tab> complete uses incorrect file separator on Windows

Submitted by:  Rik <rik5>
Submitted on:  Wed 27 Nov 2013 10:45:54 PM UTC  
 
Category: InterpreterSeverity: 2 - Minor
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Microsoft Windows

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Tue 03 Dec 2013 09:14:44 PM UTC, comment #4:

I committed several changesets which remove Octave's differences in behavior with respect to file separator.

http://hg.savannah.gnu.org/hgweb/octave/rev/1e9cb13faa7a
http://hg.savannah.gnu.org/hgweb/octave/rev/832ecfda1d3c
http://hg.savannah.gnu.org/hgweb/octave/rev/427412d40f1a
http://hg.savannah.gnu.org/hgweb/octave/rev/70e83c641b48

It would still be nice to have the correct file separator displayed when using <Tab>, but it shouldn't lead to any problems with Octave now.

Rik <rik5>
Project Administrator
Fri 29 Nov 2013 10:49:55 AM UTC, comment #3:

Thinking about this some more...

The canonicalize function would only need to run on Windows. After all, why fix something that's not broken? That is, scratch my bullet point about Unixy systems, it's irrelevant.

Messing with what Readline returns on completion is beside the point IMO. Even on Windows, you can be conditioned into using '/' for dir separators if you're routinely using e.g. the MinGW shell or Git for Windows.

Philipp Kutin <pkutin>
Thu 28 Nov 2013 11:06:08 PM UTC, comment #2:

Personally, I'd handle such a case by normalization. Which combinations are possible?

- On Windows, '/' is disallowed in file names (thanks goodness!)
- On Unixy systems, '\' could be part of a file name I think, but in a shell that would be a recipe for ambiguities and general disaster. If I saw such a name on my file system, I'd see how to get rid of it ASAP!

So maybe whenever a file name is expected, it should be passed through some "canonicalize_slashes()" function? That one would translate all [\/] to the proper slash for the given platform...

Just my two cents, not very deeply thought out.

Philipp Kutin <pkutin>
Thu 28 Nov 2013 08:51:23 PM UTC, comment #1:

As to your last sentence:

Windows doesn't accept "/" (or "\", obviously) within filenames.
("\" only works as path separator, once translated to the Windows side)

Philip Nienhuis <philipnienhuis>
Project Member
Wed 27 Nov 2013 10:45:54 PM UTC, original submission:

When using <Tab> to complete a directory name at the command line, the generated file separator charactor is always the UNIX character '/'. Instead, Octave (and really Readline), should append the correct filesep() character for the OS in question--in this case '\'.

Three instances of problems arising from this are detailed below. To find others, grep for comparisons to filesep in the scripts directory.

All examples assume a directory bin/ in the current directory.

The failure results from the fact that ls_command() on Windows is

and dir interprets a '/' character as an option leader.

fails because it is looking for either a bare directory name or a name with the appended filesep. The same thing exists for filedemos.

Finally:

This is super-annoying because the warning message is so unrelated to the actual problem.

One coding approach would be to fix Octave's interaction with Readline so that it returns the correct file separator.

A second approach would be to code defensively and accept either file separator '/' or '\' at the end. This would be a problem if there were actual files that used these two characters as could happen (at low probability as these are not good choices for filename characters).

Rik <rik5>
Project Administrator

 

(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 pkutin (Posted a comment)
  • -unavailable- added by rik5 (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):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup