Bug 236559 - Error in the pwd man page
Summary: Error in the pwd man page
Status: New
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 22:27 UTC by vermaden
Modified: 2019-05-25 05:20 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vermaden 2019-03-15 22:27:23 UTC
The man pwd on FreeBSD - https://man.freebsd.org/pwd - states:

> If no options are specified, the -P option is assumed.

... which is a lie, the -L is assumed - same as with POSIX link below:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pwd.html

Solution/Diff/Patch:
- If no options are specified, the -P option is assumed.
+ If no options are specified, the -L option is assumed.

Regards,
vermaden
Comment 1 Mark Johnston freebsd_committer 2019-03-20 16:13:04 UTC
The code suggests otherwise:

        physical = 1;
        while ((ch = getopt(argc, argv, "LP")) != -1)
                switch (ch) {
                case 'L':   
                        physical = 0;
                        break;
                case 'P':
                        physical = 1;                                  
                        break;

It also appears to work as documented:

> mkdir foo
> ln -s foo bar
> cd bar
> /bin/pwd
/home/mark/foo
> /bin/pwd -L
/home/mark/bar
> 

I suspect the problem is that the shell may provide its own pwd builtin which does indeed behave differently.
Comment 2 vermaden 2019-03-22 12:29:20 UTC
(In reply to Mark Johnston from comment #1)
So shell builtin (ZSH) behaves correctly with POSIX standards.

IMHO FreeBSD should also be correct with POSIX standards so option -L should be assumed in FreeBSD's pwd.

I am not gonna 'fight' for this - you will do what you want - but that is my opinion.

Regards,
vermaden
Comment 3 Mark Johnston freebsd_committer 2019-03-22 14:24:43 UTC
(In reply to vermaden from comment #2)
It's mostly a question of whether changing the default will break existing  scripts.  sh, bash and zsh use a builtin implementation for pwd, but tcsh in the base system does not, so I expect that such a change would cause a fair amount of pain.

We should update the pwd(1) man page to note that we are not compliant with the standard.