diff --git a/dotfiles/run.sh b/dotfiles/run.sh index 8c6a8ec..7c75e71 100644 --- a/dotfiles/run.sh +++ b/dotfiles/run.sh @@ -12,10 +12,11 @@ if [ -n "$${DOTFILES_URI// }" ]; then if [ "$DOTFILES_USER" = "$USER" ]; then coder dotfiles "$DOTFILES_URI" -y 2>&1 | tee ~/.dotfiles.log else - # The "eval echo ~$DOTFILES_USER" part is used to dynamically get the home directory of the user, see https://superuser.com/a/484280 - # sudo -u coder sh -c 'eval echo ~$DOTFILES_USER' -> "/home/coder" - # sudo sh -c 'eval echo ~$DOTFILES_USER' -> "/root" + # The "eval echo ~$USER" part is used to dynamically get the home directory of the user, see https://superuser.com/a/484280 + # eval echo ~$USER' -> "/home/coder" + # eval echo ~${DOTFILES_USER:-root}' -> "/root"" - sudo -u "$DOTFILES_USER" sh -c "$(which coder) dotfiles \"$DOTFILES_URI\" -y 2>&1 | tee -a $(eval echo ~\'$DOTFILES_USER\')/.dotfiles.log" - fi + CODER_BIN=$(which coder) + DOTFILES_USER_HOME=$(eval echo ~"$DOTFILES_USER") + sudo -u "$DOTFILES_USER" sh -c "'$CODER_BIN' dotfiles '$DOTFILES_URI' -y 2>&1 | tee '$DOTFILES_USER_HOME'/.dotfiles.log" fi fi