Bug 236559 - Error in the pwd man page
Summary: Error in the pwd man page
Status: Closed Not A Bug
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2019-03-15 22:27 UTC by Slawomir Wojciech Wojtczak
Modified: 2019-10-14 13:07 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
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:

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

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;
                case 'P':
                        physical = 1;                                  

It also appears to work as documented:

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

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.

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.