pwd default behavior

0 views
Skip to first unread message

Simon Wollwage

unread,
Feb 6, 2026, 1:20:28 AMFeb 6
to freebsd-...@freebsd.org

While reading the code for /bin/pwd, I noticed that the default behavior
in the code is to assume -P if no arguments are supplied, but according
to POSIX it shoud be -L
(https://pubs.opengroup.org/onlinepubs/9799919799/utilities/pwd.html)

Is it for convenience reasons or other technical reasons? Seems like an
easy change to make it compliant.

Dag-Erling Smørgrav

unread,
Feb 6, 2026, 11:30:50 AM (14 days ago) Feb 6
to Simon Wollwage, freebsd-...@freebsd.org
It makes very little difference in practice as pwd(1) is usually a shell
built-in, but: https://reviews.freebsd.org/D55146

DES
--
Dag-Erling Smørgrav - d...@FreeBSD.org

Jin Guojun[VFF]

unread,
Feb 6, 2026, 1:01:37 PM (14 days ago) Feb 6
to ques...@freebsd.org
It does make some difference because one wants to know where one really
is at :-)

Since there is another command "dirs" which does "pwd -L", so pwd
defaulting to -P makes sense to provide the real location.

-Jin


Chris Hill

unread,
Feb 6, 2026, 1:19:44 PM (14 days ago) Feb 6
to Jin Guojun[VFF], ques...@freebsd.org
On Fri, 6 Feb 2026, Jin Guojun[VFF] wrote:
`dirs` exists in csh. In my shell, /bin/sh, there is no `dirs` and `pwd`
defaults to the -L behavior.

--
Chris Hill ch...@monochrome.org

Jin Guojun[VFF]

unread,
Feb 6, 2026, 3:14:56 PM (14 days ago) Feb 6
to Chris Hill, ques...@freebsd.org
The man page should be updated to reflect the different behaviors
between sh and csh.


Dag-Erling Smørgrav

unread,
Feb 7, 2026, 6:12:21 AM (13 days ago) Feb 7
to Jin Guojun[VFF], Chris Hill, ques...@freebsd.org
"Jin Guojun[VFF]" <jgu...@gmail.com> writes:
> The man page should be updated to reflect the different behaviors
> between sh and csh.

No. The pwd manual page is for /bin/pwd. There are separate manual
pages for sh and csh, and yet another that lists shell builtins. Note
also that csh does not have a pwd builtin.
Reply all
Reply to author
Forward
0 new messages