bugGNU Core Utilities - Bugs: bug #24949, coreutils pwd not implementing...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #24949: coreutils pwd not implementing latest POSIX features

Submitted by:  Paul D. Smith <psmith>
Submitted on:  Wed 26 Nov 2008 08:50:44 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Eric Blake <ericb>
Open/Closed: Closed

Mon 23 Mar 2009 08:53:18 PM UTC, comment #3:

How about the attached patch?

(file #17780)

Eric Blake <ericb>
Project AdministratorIn charge of this item.
Mon 01 Dec 2008 02:04:13 AM UTC, comment #2:

The problem is that without -P I can't invoke pwd from things like Perl portably. If I use "my $pwd = `pwd`;" and it runs a shell and uses the shell builtin version of pwd, then I get the wrong thing (I explicitly want the "real" path; what POSIX defines "pwd -P" to return).

But on the other hand, if I use "my $pwd = `pwd -P`;", which is what a correct POSIX-conforming script would do, and it runs coreutils pwd instead of a shell builtin, I get a syntax error.

In short, this is a big drag.

It would be great if, at least, coreutils pwd handled the -P option (since that's what it does by default it could just accept the option and behave as it does now). In other words, I think Reuben Thomas's solution here: http://lists.gnu.org/archive/html/bug-coreutils/2008-10/msg00259.html is acceptable.

On the other hand, I think it would not actually be that difficult to implement -L. It seems to me that Eric Blake's description of what it would take to adhere to the POSIX standard, as he describes here: http://lists.gnu.org/archive/html/bug-coreutils/2008-10/msg00258.html is more complicated than necessary. We do not need to strip "." or ".." from the value of $PWD. All we need to do is determine if the value of $PWD is (a) an absolute path, and (b) it refers to the current directory, and (c) it does not contain "." or ".." as filename elements. Of these the only tricky bit AFAICS is (b); we would need to do something like compare the device/inode values of the directory pointed to by $PWD and the current directory to be sure they had the same value. I'm not sure if glib provides this type of functionality.

If all those conditions are met, then "pwd" and "pwd -L" print the value of $PWD. If any of those conditions are not met, or if the user asks for "pwd -P", then we print the absolute pathname determined the same way we determine it today.

Paul D. Smith <psmith>
Thu 27 Nov 2008 05:15:48 AM UTC, comment #1:

This has been brought up repeatedly in the past; see this thread:

http://lists.gnu.org/archive/html/bug-coreutils/2008-10/msg00293.html

Eric Blake <ericb>
Project AdministratorIn charge of this item.
Wed 26 Nov 2008 08:50:44 PM UTC, original submission:

I've noticed that in the POSIX standard (The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition), the pwd utility is expected to take two options:

It doesn't appear that the coreutils implementation of pwd supports this.

I realize that most shells including bash have a pwd builtin which is typically used when the user runs "pwd". However, pwd is not required to be a shell builtin by POSIX, and so a strictly conforming sh implementation is not required to provide it. It seems to me that coreutils "pwd" should conform.

What do you all think? I can provide a patch if it would be something you're interested in.

Paul D. Smith <psmith>

 

Attached Files
file #17780:  coreutils.patch1 added by ericb (9KiB - application/octet-stream - First cut at 'pwd -L/-P')

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ericb (Posted a comment)
  • -unavailable- added by psmith (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 19 May 2009 11:35:21 PM UTCericbStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Mon 23 Mar 2009 08:53:59 PM UTCericbStatusNone=>In Progress
      Assigned toNone=>ericb
    Mon 23 Mar 2009 08:53:18 PM UTCericbAttached File-=>Added coreutils.patch1, #17780

    Back to the top


    Powered by Savane 3.1-cleanup1