From 8f24eebb2a134100079ef0861696a8c955195754 Mon Sep 17 00:00:00 2001 From: Francesco Minnocci Date: Sun, 24 Jan 2021 13:18:53 +0100 Subject: [PATCH] Workaround for zsh users setting ZDOTDIR in ~/.zshenv who have no ~/.profile. --- bin/mailsync | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/mailsync b/bin/mailsync index 42cd4e0..a6b0263 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -16,6 +16,11 @@ pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync wil # Run only if not already running in other instance pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;} +# Workaround for zsh users who only have .zshenv in their $HOME. +usersh="$(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd)" +[ "$usersh" = /usr/bin/zsh ] && eval "$(grep -h -- \ + "^\s*\(export \)\?\(ZDOTDIR\|XDG_CONFIG_HOME\|XDG_DATA_HOME\)=" \ + "$HOME/.zshenv" 2>/dev/null)" # First, we have to get the right variables for the mbsync file, the pass # archive, notmuch and the GPG home. This is done by searching common profile # files for variable assignments. This is ugly, but there are few options that