Bug 236559

Summary: Error in the pwd man page
Product: Documentation Reporter: Slawomir Wojciech Wojtczak <vermaden>
Component: Manual PagesAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Not A Bug    
Severity: Affects Many People CC: doc, markj
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Slawomir Wojciech Wojtczak 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 freebsd_triage 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 Slawomir Wojciech Wojtczak 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 freebsd_triage 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.