bugGNU Octave - Bugs: bug #57587, [Feature Request] Implement code...

 
 

bug #57587: [Feature Request] Implement code for symlinks to follow logical structure

Submitted by:  Lars Kindermann <larskindermann>
Submitted on:  Mon 13 Jan 2020 03:37:42 AM UTC  
 
Category:  Interpreter Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

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 14 Jan 2020 03:56:30 PM UTC, comment #14: 

I agree; Feature Request.

The one "script compatibility" thing that logical symlink dirs provide is that when you do a `cd foo` where foo is a symlink, and then you do a `cd ..`, you end up in a different location. But that's an unusual case, and `cd ..` in scripts is bad practice anyway. So this is not at all pressing.

Andrew Janke <apjanke>
Tue 14 Jan 2020 03:53:44 PM UTC, comment #13: 

Rik, I agree.  There are also complexity of implementation and maintenance issues to consider.

John W. Eaton <jwe>
Project Administrator
Tue 14 Jan 2020 03:43:26 PM UTC, comment #12: 

So to summarize, there is no driving reason, such as compatibility with Matlab or consistency with all other programs, to require logical structure.  But, it is a useful feature and, if implemented, could easily be switched on/off with a preference meaning there are no lock-in effects for the project or users.

Sounds like this should be made a Feature Request and if someone wants to implement it they can.

Rik <rik5>
Project Administrator
Tue 14 Jan 2020 03:39:50 PM UTC, comment #11: 

So at least in --traditional mode, I assume we would want to use physical names.

If we did allow following symbolic link names as an option, would there be a problem for reliability of scripts?  Is that a problem for shells that have this feature?

I think there may be other issues for Octave, like what is supposed to go in the load-path?  The canonical physical name of the file or or the symbolic link?  Should that depend on the setting for following symbolic links?

Since Octave borrows from readline and bash, I think we may have had some code to track symbolic links in the past?

In any case, simply using the canonical physical directory name is far simpler.

John W. Eaton <jwe>
Project Administrator
Tue 14 Jan 2020 02:45:48 PM UTC, comment #10: 

> WDMD?


Physical.

Andrew Janke <apjanke>
Tue 14 Jan 2020 01:07:07 PM UTC, comment #9: 

WDMD?

John W. Eaton <jwe>
Project Administrator
Tue 14 Jan 2020 12:37:42 PM UTC, comment #8: 

Personally, I would prefer "logical". I use a bunch of symlinks in my home directory, including ones for ~/Desktop and ~/Documents/Octave, and would prefer to see dirs in terms of that symlink layout instead of what they resolve to.

Andrew Janke <apjanke>
Tue 14 Jan 2020 10:46:06 AM UTC, comment #7: 

I just investigated how several shells and interpreters handle symlinks by executing the respective equivalent to

cd symlink
pwd
cd ..
pwd

bash, dash, zsh, fish: logical (can be switched to physical)

tcsh: physical (can be switched to logical)

csh: $cwd logical, 'cd ..' physical

busybox : physical

thunar, nautilus: logical

tcl: pwd logical but 'cd ..' physical

perl, python, R, php, octave: physical

libreoffice (dialogs, fields and scripts): logical

So almost all shells implement both logical and physical maneuvering, most default to logical behaviour but script languages typically provide no logical maneuvering.

A nice example of a typical discussion presenting all possible strong opinions about this topic is here: https://github.com/fish-shell/fish-shell/issues/1957

Personally, I would love Octave to behave "logical", because getting physical on demand would still be easy. And staying in the logical namespace is currently impossible.

Lars Kindermann <larskindermann>
Mon 13 Jan 2020 10:21:31 PM UTC, comment #6: 

It seems that several projects who developed scripts or interpreters had this discussion at some point. To summarize some typical arguments for and against symbolic path tracking (bash style) vs. automatic canonicalizing to physical paths (csh style):

Bash style seems more logical and less surprising for the user.
cd 'xyz' and cd '..' are always symmetric, inverse operations. Code always works identically for real subdirs and symlinks.

It's not easy to implement. There is no system API for this availabe. Like in Bash, a complex tracking logic must be implemented in the interpreter itself, with many possible pitfalls.

If symbolic tracking is the default implemented behaviour, it is very easy for the user to code the physical behaviour if desired:

cd(canonicalize_file_name(path))
cd(canonicalize_file_name('..'))
pwd(canonicalize_file_name('.'))

The other way round, if not implemented in the interpreter, there is no easy method to stay in the symbolic namespace, the user has to code all the complex tracking logic himself.

But in fact, most interpreters finally stayed with the standard API calls, aka csh style...

Lars Kindermann <larskindermann>
Mon 13 Jan 2020 07:00:02 PM UTC, comment #5: 

As a bash user, I certainly appreciate the "logical" default cd behavior, but I agree that keeping the current "physical" behavior is sensible and of course easier.

Mike Miller <mtmiller>
Project Administrator
Mon 13 Jan 2020 06:27:21 PM UTC, comment #4: 

This seems like an opinion question, rather than a definitive bug, so I changed the Summary to reflect that.

Octave can probably implement either convention, although staying with physical structure would be easier because that is what is already implemented.  As a tcsh shell user, I'm surprised by the opposite behavior, but I could learn to accept that.

It would probably be wise to ask this question on the Octave Maintainer's list and get a broader survey of opinion then just the users who happen to see this bug report.

Rik <rik5>
Project Administrator
Mon 13 Jan 2020 06:02:28 AM UTC, comment #3: 

Bash with default setting in Debian (set +P) is transparent, sh and
ash also, csh uses physical structure instead.

Lars Kindermann <larskindermann>
Mon 13 Jan 2020 04:48:28 AM UTC, comment #2: 

Which shell?  Bash has "set -P" and "set +P" and also a -P option for the cd command to control whether it tracks symbolic links or uses the physical directory structure.

John W. Eaton <jwe>
Project Administrator
Mon 13 Jan 2020 04:32:00 AM UTC, comment #1: 

Sorry, I have to correct myself. Both perl and python behave exactly like octave. Just the shell handles symlinks in a truly transparent manner.

Lars Kindermann <larskindermann>
Mon 13 Jan 2020 03:37:42 AM UTC, original submission:  

Symlinks are not handeled transparently in Octave, they are always dereferenced on entry, both in scripts (cd) and in the GUI.

I'm not sure if this is to be considered a bug, probably it has been discussed before. But the behaviour is different from all other scripting languages I'm aware of, including the shells. But I don't know how Matlab behaves.

To demonstrate, create two directories which share a common subdirectory:

mkdir proj1
mkdir proj1/data
mkdir proj2
symlink ../proj1/data proj2/data

An often used script construct like

cd proj1
pwd
cd data
#do stuff
cd ..
pwd

results as expected in

ans = /home/kinder/octave/proj1
ans = /home/kinder/octave/proj1

but doing the same with the symlinked subdir

cd proj2
pwd
cd data
#do stuff
cd ..
pwd

changes the location. The "cd dir; cd .." combination does not return to the origin:

  

ans = /home/kinder/octave/proj2
ans = /home/kinder/octave/proj1

So scripts may behave differently on normal vs. symlinked directory structures.

Lars Kindermann <larskindermann>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by larskindermann (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-14 rik5 Severity3 - Normal => 1 - Wish
        Item GroupOther => Feature Request
        StatusNone => Confirmed
        SummaryShould symlinks follow physical structure or logical structure? => [Feature Request] Implement code for symlinks to follow logical structure
    2020-01-13 rik5 SummarySymlinks are not handeled transparently => Should symlinks follow physical structure or logical structure?

    Back to the top


    Powered by Savane 3.5