msmtpq: create parent dirs for $Q and $LOG

When I first tried to use msmtpq, I was a little bit confused by the
behavior of the Q and LOG variables. README.msmtpq does say that the
directories for those variables should be created before you run msmtpq,
but I didn’t notice that when I was first skimming through it.

This change makes msmtpq more resilient in those situations. Now, msmtpq
will not only create a directory for $Q and a directory for $LOG but
also create parent directories for those directories if necessary.

This change was inspired by a patch that was included in a nixpkgs PR:
<f8e3437ef2 (diff-db16f24325854530247bb84d212795a677d9477a0507fb9aa174f561653c5138R12)>
Jason Yundt 2 months ago committed by Martin Lambers
parent 8139cf6207
commit 43f0e4bece
  1. 3

@ -72,7 +72,7 @@ fi
## the queue dir - export this variable to reflect where you'd like it to be (no quotes !!)
[ -d "$Q" ] || mkdir -m 0700 "$Q" || \
[ -d "$Q" ] || mkdir -m 0700 -p "$Q" || \
err '' "msmtpq : can't find or create msmtp queue directory [ $Q ]" '' # if not present - complain ; quit
## set the queue log file var to the location of the msmtp queue log file
@ -86,6 +86,7 @@ Q=${Q:-~/.msmtp.queue}
## the queue log file - export this variable to change where logs are stored (but no quotes !!)
## Set it to "" (empty string) to disable logging.
[ -v LOG ] || LOG=~/log/msmtp.queue.log
[ -d "$(dirname "$LOG")" ] || mkdir -p "$(dirname "$LOG")"
## ======================================================================================
## msmtpq can use the following environment variables :