fix(installer): set `$HOME` if not defined (#10680)
Fixes #10680
Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index e64e3906397f606fd8e46d2c6d3b67298b7d7684..c80c0936558318d674131482fcfce71701488427 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -42,13 +42,17 @@ set -e
6 # $USER is defined by login(1) which is not always executed (e.g. containers)
7 # POSIX: https://pubs.opengroup.org/onlinepubs/009695299/utilities/id.html
8 USER=${USER:-$(id -u -n)}
9+# $HOME is defined at the time of login, but it could be unset. If it is unset,
10+# a tilde by itself (~) will not be expanded to the current user's home directory.
11+# POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
12+HOME="${HOME:-$(getent passwd $USER | cut -d: -f6)}"
131415 # Track if $ZSH was provided
16 custom_zsh=${ZSH:+yes}
1718 # Default settings
19-ZSH=${ZSH:-~/.oh-my-zsh}
20+ZSH="${ZSH:-$HOME/.oh-my-zsh}"
21 REPO=${REPO:-ohmyzsh/ohmyzsh}
22 REMOTE=${REMOTE:-https://github.com/${REPO}.git}
23 BRANCH=${BRANCH:-master}