Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0e6212bed6f8ddbb51977cfc3048212a0f3f5f02
Ticket: 3570244fffffffffffffffffffffffffffffffff
"cd .." behaves wrong if last element in pwd is a symlink
User & Date: wastl-nagel on 2012-09-20 21:26:59
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    If the last element of a the current path (pwd) is a symbolic link with a trailing slash the command
      cd ..
    does not change into the parent directory but stays in the current directory.
    
    In addition, when the link target is a relative path containing ".." or "." the pwd after "cd .." may require normalization.
    
    Related / possible duplicate of "cd .. from link in Windows confuses Tcl - ID: 3183016"
    
    
    bash> pwd
    /tmp/test
    bash> mkdir /tmp/dir
    bash> ln -sf /tmp/dir link_abs
    bash> tclsh
    % cd link_abs
    % pwd
    /tmp/test/link_abs
    % cd ..
    % pwd  ;# ok we are in /tmp (/tmp/test would be also plausible)
    /tmp
    % exit
    
    bash> ln -sf /tmp/dir/ link_abs_trailing_slash
    bash> tclsh
    % cd link_abs_trailing_slash
    % pwd
    /tmp/test/link_abs_trailing_slash
    % cd ..  ;# should cd to /tmp (or /tmp/test)
    % pwd    ;# surprise: we stay in same effective directory
    /tmp/dir
    % exit
    
    bash> ln -sf /tmp/dir link_rel
    bash> tclsh
    % cd link_rel
    % pwd
    /tmp/test/link_rel
    % cd ..
    % pwd    ;# ok, but should be normalized
    /tmp/test/..
    % file normalize [pwd] 
    /tmp
    % exit
    
    bash> ln -sf ../dir/ link_rel_trailing_slash
    bash> tclsh
    % cd link_rel_trailing_slash
    % pwd
    /tmp/test/link_rel_trailing_slash
    % cd ..
    % pwd    ;# surprise
    /tmp/dir
    % exit
    
    bash> ln -sf ./link_abs link2link
    bash> tclsh
    % cd link2link
    % pwd
    /tmp/test/link2link
    % cd ..  ;# now we are in /tmp/test (also ok)
    % pwd    ;# but should be normalized
    /tmp/test/.
    % file normalize [pwd] 
    /tmp
    
    % puts "$::tcl_patchLevel, $::tcl_platform(os) $::tcl_platform(osVersion)"
    8.5.11, Linux 3.2.0-30-generic
    % exit
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "wastl-nagel"
  10. subsystem changed to: "16. Commands A-H"
  11. title changed to:
    "cd .." behaves wrong if last element in pwd is a symlink
    
  12. type changed to: "Bug"