help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird problem with function ls or system("ls...")


From: John W. Eaton
Subject: Re: Weird problem with function ls or system("ls...")
Date: Tue, 28 Jul 2009 16:45:11 -0400

On 28-Jul-2009, Christian Weickhmann wrote:

| My ls gives me: ls (GNU coreutils) 6.10
| 
| > does. Because apparently, you have no file that matches * in the working
| > directory (. and .. can't be globbed). So the shell just forwards the
| > star as an argument. Then ls complains because it can't find a file
| > called *.
| 
| Look at the different behaviour:
| 
| The directory is empty.
| But for ls * it gives me an empty set but return code 0 (all fine).
| For ls *a* it gives me an error (return code 2).
| 
| If both would return an error, I'd say; yes it's consistent. :)
| This way I wonder why it is.
| 
| John stated that octave uses the system's ls command, so I will look at the 
| mailinglists there.
| 
| Thanks so far. (Still weird though... ;) Today I thought my computer just 
| mocks me...).

I think we are getting off topic for the Octave help list, but if you
execute

  echo *

in an empty directory on your system, does it print '*'?  If so, then
for

  ls *

I would expect that '*' should be passed to ls, which should probably
tell you that there is no file or directory named '*'.  If echo
doesn't print anything, then ls isn't seeing any arguments, and so it
returns nothing.  In that case, then the problem might be in bash (or
whatever shell it is that you are using), because I don't think it
should expand '*' to nothing if there are no matches (but I'm not
absolutely sure about what the correct behavior is).  So what version
of bash do you have?  Or, if you aren't using bash, then what shell do
you have and what is the version?  Is /bin/sh also bash on your system?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]