Date: Sat, 24 Dec 2022 22:53:46 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 268547] /bin/sh 'cd' should get user's home directory from password database if HOME is unset Message-ID: <bug-268547-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268547 Bug ID: 268547 Summary: /bin/sh 'cd' should get user's home directory from password database if HOME is unset Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: jschauma@netmeister.org Created attachment 239007 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D239007&action= =3Dedit patch to cd to fall back to getpwuid->pw_dir if HOME is unset POSIX requires that the 'cd' command use the $HOME environment variable (if that is set) when no operand is given. It explicitly notes that behavior of 'cd' with no operand when $HOME is uns= et is implementation defined. It then notes:=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20 "A common extension when HOME is undefined is to get the login directory fr= om the user database for the invoking user. This does not occur on System V implementations." If HOME is unset, /bin/sh currently fails with the error message "HOME not set". Instead, I think it would be useful to try to determine the user's ho= me directory via a getpwuid() lookup. Attached is a diff to implement this proposed change. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-268547-227>