linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Bowler <nbowler@elliptictech.com>
To: yuyichao-mit <yuyichao@mit.edu>
Cc: "richard -rw- weinberger" <richard.weinberger@gmail.com>,
	"Lars Täuber" <taeuber@bbaw.de>,
	linux-kernel@vger.kernel.org,
	linux-c-programming@vger.kernel.org
Subject: Re: extra slash in current path
Date: Thu, 23 Jun 2011 10:27:06 -0400	[thread overview]
Message-ID: <20110623142706.GA13310@elliptictech.com> (raw)
In-Reply-To: <BANLkTin9bQ4hzs-odYU-Gxy-f-T+HLLAdQ@mail.gmail.com>

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/)

  parent reply	other threads:[~2011-06-23 14:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23 13:14 extra slash in current path yuyichao-mit
2011-06-23 13:17 ` Alessandro Suardi
     [not found]   ` <BANLkTik3iMqZJiEY1+DYS2T9=+q2x2=5pQ@mail.gmail.com>
2011-06-23 13:26     ` yuyichao-mit
     [not found] ` <20110623153116.404f2a63.taeuber@bbaw.de>
     [not found]   ` <BANLkTinOb-4Xm_W2fmzivk6jBJwjeHYKVA@mail.gmail.com>
     [not found]     ` <BANLkTimXH8K91cZ69oPRu=wbYt9JgBadfA@mail.gmail.com>
2011-06-23 14:11       ` yuyichao-mit
2011-06-23 14:25         ` richard -rw- weinberger
2011-06-23 14:27         ` Nick Bowler [this message]
2011-06-23 14:31         ` Michael Tokarev
2011-06-23 14:53           ` yuyichao-mit
     [not found]           ` <20110623165206.d88dcbb3.taeuber@bbaw.de>
     [not found]             ` <BANLkTimdzyT6w2LoKtTjhHTKF5d6zWXFGw@mail.gmail.com>
2011-06-23 15:02               ` 俞颐超

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110623142706.GA13310@elliptictech.com \
    --to=nbowler@elliptictech.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.weinberger@gmail.com \
    --cc=taeuber@bbaw.de \
    --cc=yuyichao@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).