octave-maintainers
[Top][All Lists]
Advanced

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

Re: Matlab incompatibility: cd and which


From: John W. Eaton
Subject: Re: Matlab incompatibility: cd and which
Date: Mon, 14 Oct 2013 16:26:10 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

On 10/14/2013 04:03 PM, PhilipNienhuis wrote:
John W. Eaton wrote
On 10/14/2013 03:36 PM, PhilipNienhuis wrote:
Michael Goffioul wrote

<snip>
2) "cd" without argument changes to home dir, while in Matlab it simply
returns the current directory.

Also on Linux-based Matlab? or only on Windows? (could be OS-dependent)
I can't test now, my ML prerelease has expired a few weeks ago.

What does ML do on Mac OSX?

I don't think the behavior is dependent on the OS.  There is certainly
no mention of that in the Matlab docs.

Hmm... there's more mention of Matlab behavior missing in their docs :-)

But I agree the on-line ML doc for "cd" is quite unambiguous.

Sure, and the behavior of cd in Unixy shells  is also quite well
established.

And at least the effect of "cd" is consistent between Windows and Mac OSX.

Perhaps it can be made configurable; but I can't imagine that to be a high
priorty.

No, having a configuation option for things like this is a bad idea.
We had a lot of those things in the early days of Octave and they were
a disaster.  We worked really hard to remove them.  The problem with
configuration options for features like this is that they make it
difficult to write code that works no matter what the user preference
settings happen to be.  You end up having to know all about the
various user preferences and write things like this:

  unwind_protect
    ostate = lone_cd_is_pwd (false);
    ...
    cd;
    ...
  unwind_protect_cleanup
    lone_cd_is_pwd (ostate);
  end_unwind_protect

Yes, I agree that this is a silly case and there are other ways to
write this code so that it will always work (use pwd if that's what
you want, or cd ~ if that's what you want) but the general principle
is the same: global configuration variables that change the behavior
of functions cause more trouble than they are worth.

If people really think that Matlab compatibility at this level is
paramount, then I'd say we should change Octave's bahavior to match.
But we will probably also break a some Octave code that expects "cd"
to change to the user's home directory.  We can't have it both ways.

jwe


reply via email to

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