lkml.org 
[lkml]   [2011]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: extra slash in current path
    On 2011-06-23 10:11 -0400, yuyichao-mit wrote:
    > On Thu, Jun 23, 2011 at 9:54 AM, richard -rw- weinberger
    > > Is this really a kernel issue?
    > > rw@raccoon:~> cd //
    > > rw@raccoon://> pwd
    > > //
    > > rw@raccoon://> ls -l /proc/self/cwd
    > > lrwxrwxrwx 1 rw users 0 23. Jun 15:53 /proc/self/cwd -> /
    >
    > well, that's true, but this is indeed the retrun value of get_current_dir_name.

    glibc's get_current_dir_name will honour the PWD environment variable in some
    cases, which is where the // actually comes from (i.e., it does not come
    from the kernel).

    This funny behaviour of cd is actually specified by POSIX (man 1p cd):

    8. The curpath value shall then be converted to canonical form
    as follows, considering each component from beginning to
    end, in sequence:
    [...]
    c. An implementation may further simplify curpath by
    removing any trailing slash characters that are not also
    leading slashes, replacing multiple non-leading
    consecutive slashes with a single slash, and replacing
    three or more leading slashes with a single slash. If,
    as a result of this canonicalization, the curpath
    variable is null, no further steps shall be taken.

    9. [...] The PWD environment variable shall be set to curpath.

    Cheers,
    --
    Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)


    \
     
     \ /
      Last update: 2011-06-23 16:29    [W:2.495 / U:0.424 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site