mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-18 10:22:00 +00:00
fix(installer): fix $HOME
setting if getent
is not found (macOS)
Related: https://github.com/ohmyzsh/ohmyzsh/pull/10713/files#r820219899
This commit is contained in:
parent
9350e1ff87
commit
4f0b680248
1 changed files with 3 additions and 1 deletions
|
@ -45,7 +45,9 @@ USER=${USER:-$(id -u -n)}
|
||||||
# $HOME is defined at the time of login, but it could be unset. If it is unset,
|
# $HOME is defined at the time of login, but it could be unset. If it is unset,
|
||||||
# a tilde by itself (~) will not be expanded to the current user's home directory.
|
# a tilde by itself (~) will not be expanded to the current user's home directory.
|
||||||
# POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
|
# POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
|
||||||
HOME="${HOME:-$(getent passwd $USER | cut -d: -f6)}"
|
HOME="${HOME:-$(getent passwd $USER 2>/dev/null | cut -d: -f6)}"
|
||||||
|
# macOS does not have getent, but this works even if $HOME is unset
|
||||||
|
HOME="${HOME:-$(eval echo ~$USER)}"
|
||||||
|
|
||||||
|
|
||||||
# Track if $ZSH was provided
|
# Track if $ZSH was provided
|
||||||
|
|
Loading…
Reference in a new issue