bugGNU Octave - Bugs: bug #46002, After, LIST = ls (...) each row...

 
 

bug #46002: After, LIST = ls (...) each row of LIST is an output row, not a filename

Submitted by:  Lachlan Andrew <lachlan>
Submitted on:  Sat 19 Sep 2015 12:56:37 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: LachlanOpen/Closed: Closed
Release: 4.0.0Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sat 10 Oct 2015 02:30:54 AM UTC, comment #5:

I looked at the man page for ls in BSD and it accepts the -1 argument so I added ismac() to the test. I committed the patch and credited you here (http://hg.savannah.gnu.org/hgweb/octave/rev/56333f6df823).

Rik <rik5>
Project Administrator
Sat 10 Oct 2015 12:28:11 AM UTC, comment #4:

Should the test for whether to use the '-1' argument be

so that we also add the extra argument on Mac BSD-like systems?

Rik <rik5>
Project Administrator
Fri 09 Oct 2015 11:47:31 PM UTC, comment #3:

It looks like if we really want to be Matlab compatible then we should just be returning the bare output of the system() call. See http://www.mathworks.com/help/matlab/ref/ls.html. In particular

But that just seems stupid. I think I like your patch. I will look at pushing it this weekend.

Rik <rik5>
Project Administrator
Wed 30 Sep 2015 03:41:54 AM UTC, comment #2:

Thanks for the reply, Rik.

One disadvantage of fix-by-documentation is that it still isn't compatible with Matlab.

As an aside, if we just return the output of /bin/ls, then that is the same as /bin/ls -1 (since ls detects it isn't outputting directly to a terminal); the code currently explicitly asks for "ls -C".

Lachlan Andrew <lachlan>
Project Member
Mon 21 Sep 2015 03:25:01 PM UTC, comment #1:

What about solving it by documentation? It seems reasonable to just return the output of the ls command and if the user wants something else they can chnage ls_command to 'ls -1' or use dir() or use readdir().

Rik <rik5>
Project Administrator
Sat 19 Sep 2015 12:56:37 AM UTC, original submission:

Running
help ls
states that: If the optional output LIST is requested then 'ls' returns a character array with one row for each file/directory name.

However, ls (without -l) returns multiple filenames per row:

I've attached a simple patch. If someone using unix supply their own _ls_command that didn't understand -1, it would break. A more thorough solution is to have two _ls_command_ variables: one to produce screen-ready output (columnated or otherwise) and the other to produce the character array.

Any suggestions?

Lachlan Andrew <lachlan>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #34925:  ls.patch added by lachlan (337B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by siko1056 (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by lachlan (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
    Sat 10 Oct 2015 02:30:54 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 28 Sep 2015 03:18:17 PM UTCsiko1056StatusNone=>Confirmed
    Sat 19 Sep 2015 12:56:37 AM UTClachlanAttached File-=>Added ls.patch, #34925

    Back to the top


    Powered by Savane 3.1-cleanup1