"ls" and "cd" treat ".." differently inside symlinked directories
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 1 of 1
  1. #1
    Join Date
    Jun 2008

    "ls" and "cd" treat ".." differently inside symlinked directories

    First, let me say that I'm really enjoying using Fedora 9. Thanks for a great distribution!

    Now the problem: I've been using Linux daily for well over a decade, and this is new to me.

    My development tree fails miserably now due to what seems like very strange behavior with symlinks. I notice this on both i386 and x86_64 Fedora 9 (just updated this morning, June 19).

    When you've reached a directory using a symlink and then use ".." from within that tree, the interpretation of ".." is different depending on the command. See the following example:

    [bnorman@localhost level1]$ ls -lR
    total 4
    drwxrwxr-x 3 bnorman bnorman 4096 2008-06-19 08:37 level2
    lrwxrwxrwx 1 bnorman bnorman   13 2008-06-19 08:38 link3 -> level2/level3
    total 4
    drwxrwxr-x 2 bnorman bnorman 4096 2008-06-19 08:37 level3
    total 0
    [bnorman@localhost level1]$ cd link3
    [bnorman@localhost link3]$ ls ..
    [bnorman@localhost link3]$ cd .. ; ls ; cd -
    level2  link3
    [bnorman@localhost link3]$ ls '..'
    [bnorman@localhost link3]$ cd '..' ; ls ; cd -
    level2  link3
    [bnorman@localhost link3]$
    So as an argument to ls, ".." follows the true directory structure. As an argument to "cd", it follows the symbolic path that was used to get to the current directory. gcc unfortunately also follows the true directory structure when parsing include and library paths, as well.

    I know this is not a gcc or ls problem per se; what library do they use to parse paths? The problem is the same under bash or tcsh. It is also the same on ext3 or ntfs partitions. Any suggestions?

    EDIT: "cd" is a shell builtin, and "ls" is a binary.

    Last edited by bnorman; 19th June 2008 at 08:56 PM.

Similar Threads

    By ketan_hk in forum Using Fedora
    Replies: 6
    Last Post: 6th September 2007, 01:10 AM
  2. Replies: 0
    Last Post: 29th August 2007, 05:53 PM
  3. Replies: 9
    Last Post: 21st October 2006, 12:10 PM
  4. Replies: 0
    Last Post: 23rd May 2005, 04:59 AM
  5. Replies: 0
    Last Post: 7th June 2004, 02:24 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts