fix(installer): fix `$HOME` setting if `getent` is not found (macOS)
Related: https://github.com/ohmyzsh/ohmyzsh/pull/10713/files#r820219899
Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index 93608eb7c2b0b082990b6fb65738ff6d5d6f658d..f04d0dc9c0a228a31fb3367bae5bed3450f3a52a 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -45,7 +45,9 @@ USER=${USER:-$(id -u -n)}
6 # $HOME is defined at the time of login, but it could be unset. If it is unset,
7 # a tilde by itself (~) will not be expanded to the current user's home directory.
8 # POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
9-HOME="${HOME:-$(getent passwd $USER | cut -d: -f6)}"
10+HOME="${HOME:-$(getent passwd $USER 2>/dev/null | cut -d: -f6)}"
11+# macOS does not have getent, but this works even if $HOME is unset
12+HOME="${HOME:-$(eval echo ~$USER)}"
131415 # Track if $ZSH was provided