[Bug 268547] /bin/sh 'cd' should get user's home directory from password database if HOME is unset
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 268547] /bin/sh 'cd' should get user's home directory from password database if HOME is unset"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 268547] /bin/sh 'cd' should get user's home directory from password database if HOME is unset"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 268547] /bin/sh 'cd' should get user's home directory from password database if HOME is unset"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 268547] /bin/sh 'cd' should get user's home directory from password database if HOME is unset"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 24 Dec 2022 22:53:46 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268547 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=239007&action=edit 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 unset is implementation defined. It then notes: "A common extension when HOME is undefined is to get the login directory from 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 home directory via a getpwuid() lookup. Attached is a diff to implement this proposed change. -- You are receiving this mail because: You are the assignee for the bug.