summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2022-02-21 20:10:18 +0100
committerMarc Cornellà <hello@mcornella.com>2022-02-22 21:24:43 +0100
commit9b883aa4171585995475d9ddff2ef59401199b36 (patch)
treeb0bc2e774928423aaadaa2339151233abdc62ee0 /tools
parent6f1036293cdc1af12dbe6390a061c147de1196ff (diff)
downloadzsh-9b883aa4171585995475d9ddff2ef59401199b36.tar.gz
zsh-9b883aa4171585995475d9ddff2ef59401199b36.tar.bz2
zsh-9b883aa4171585995475d9ddff2ef59401199b36.zip
fix(installer): set `$HOME` if not defined (#10680)
Fixes #10680
Diffstat (limited to 'tools')
-rwxr-xr-xtools/install.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/install.sh b/tools/install.sh
index e64e39063..c80c09365 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -42,13 +42,17 @@ set -e
# $USER is defined by login(1) which is not always executed (e.g. containers)
# POSIX: https://pubs.opengroup.org/onlinepubs/009695299/utilities/id.html
USER=${USER:-$(id -u -n)}
+# $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.
+# POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
+HOME="${HOME:-$(getent passwd $USER | cut -d: -f6)}"
# Track if $ZSH was provided
custom_zsh=${ZSH:+yes}
# Default settings
-ZSH=${ZSH:-~/.oh-my-zsh}
+ZSH="${ZSH:-$HOME/.oh-my-zsh}"
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}