bugGNU Octave - Bugs: bug #40989, ls fails if blank spaces exist in...


bug #40989: ls fails if blank spaces exist in filepath

Submitted by:  Felipe G. Nievinski <fgnievinski>
Submitted on:  Sun 22 Dec 2013 09:27:55 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:  dev Operating 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)

Tue 07 Jan 2014 11:16:24 PM UTC, comment #8: 
Rik <rik5>
Project Administrator
Thu 02 Jan 2014 07:46:03 PM UTC, comment #7: 

There is a problem with cset 05a53cc522b7 (http://hg.savannah.gnu.org/hgweb/octave/rev/05a53cc522b7) so I am re-opening the bug.  The patch wraps all non-options in double quote characters.  However, following the wrapping there is a regexprep call which escapes all non-word characters like the double quote character.  This makes ls unusuable whenever you have an actual file name.  See the following example:

ls /home
ls: cannot access "/home": No such file or directory
error: ls: command exited abnormally with status 2

You might get away with modifying the regexprep to not include double quotes on line 80 of ls.m

args = regexprep (args, '([^\w.*? -])', '\\$1');


args = regexprep (args, '([^\w.*? -"])', '\\$1');

But I haven't thought through all of the implications.

Rik <rik5>
Project Administrator
Mon 30 Dec 2013 10:21:20 PM UTC, comment #6: 

works on linux, too:

'c' is a script from the file /home/fgnievinski/a b/c.m

Felipe G. Nievinski <fgnievinski>
Sun 29 Dec 2013 07:06:31 PM UTC, comment #5: 

addpath doesn't seem to have any problem with spaces:

    mkdir('a b')
    system('touch "a b/c.m"')
    addpath('a b')
    which c
    rmpath('a b')
    delete('a b/c.m')
    rmdir('a b')


'c' is a script from the file C:\Users\fgnievinski\a b\c.m

can you confirm on linux?

Felipe G. Nievinski <fgnievinski>
Sun 29 Dec 2013 03:16:59 PM UTC, comment #4: 

Thanks, I have pushed your patch:


I don't know about addpath. Can you test yourself? The most common situation of spaces in the path occurs in Windows, and I don't have access to Windows. So far we have recommended people to simply avoid spaces in the path. I suspect that the problem lies deeper than the simple fix for ls that you have provided.

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Wed 25 Dec 2013 12:57:05 PM UTC, comment #3: 

here's the mercurial patch

I don't know about addpath -- should a separate bug be opened?

(file #30090)

Felipe G. Nievinski <fgnievinski>
Tue 24 Dec 2013 09:34:15 PM UTC, comment #2: 

Sorry, I see you did use "endif". We prefer to use ! for negation instead of ~.

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Tue 24 Dec 2013 09:33:18 PM UTC, comment #1: 

We prefer Octave style in m-files, not Matlab style. Can you please look at the style of the code you're patching and follow it? For example, no single-quoted strings, spaces before ( in function calls but not in indexing calls, informative closing block statements (e.g. endif, not plain end).

Also, can you please produce hg csets instead of plain diffs?

As to the content of the patch itself, I think this doesn't fundamentally solve the problem with spaces in the pathname. For example, does addpath work correctly if there are spaces?

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Sun 22 Dec 2013 09:27:55 PM UTC, original submission:  

without the patch attached these calls fail:

 ls('c:\program files')
 ls('c:\program files\w*')
 ls('/od', 'c:\program files')

Felipe G. Nievinski <fgnievinski>


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

Attach Files:

Attached Files
file #30090:  bug40989.patch added by fgnievinski (1KiB - application/octet-stream)
file #30067:  ls.m.diff added by fgnievinski (277B - application/octet-stream)


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 jordigh (Posted a comment)
  • -email is unavailable- added by fgnievinski (Submitted the item)

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

    Only project members can vote.




    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-07 rik5 StatusIn Progress => Fixed
        Open/ClosedOpen => Closed
    2014-01-02 rik5 StatusFixed => In Progress
        Open/ClosedClosed => Open
    2013-12-29 jordigh StatusNone => Fixed
        Open/ClosedOpen => Closed
    2013-12-25 fgnievinski Attached File- => Added bug40989.patch, #30090
    2013-12-22 fgnievinski Attached File- => Added ls.m.diff, #30067

    Back to the top

    Powered by Savane 3.5