-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RFC5322 subject header for zed_notify_email() #13440
Conversation
Could you squash your two commits and modify the commit message?:
|
One of the lines in your commit message is over 80 chars long. Would you mind breaking it into two lines? (see my earlier commit message example) We typically don't have > 80 chars in a commit line unless there's a compelling reason to. Other than that, it looks good to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-placing /dev/null ($# -eq 1) fails, and editing the message in-place breaks expectations (and possibly mangles the message repeatedly forever); this is better served as
if [ "${ZED_EMAIL_OPTS%@SUBJECT@*}" = "${ZED_EMAIL_OPTS}" ]; then
[ -s "${pathname}" ] && sed -i "1iSubject: ${subject}
" "${pathname}" || echo "Subject: ${subject}"
else
cat "${pathname}"
fi | eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} >/dev/null 2>&1
or, well,
{
[ "${ZED_EMAIL_OPTS%@SUBJECT@*}" = "${ZED_EMAIL_OPTS}" ] && echo "Subject: ${subject}"
cat "${pathname}"
} | eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} >/dev/null 2>&1
@nabijaczleweli thanks, good catch! I adressed those issues. Also I've added a default subject, so mail notifications don't get discarded if the subject is empty. @tonyhutter Should I squash those commits? (I didn't since I'd see them as different changes but can do if that's better.) I tested with: #!/bin/sh
. "./zed-functions.sh"
. "./zed.rc"
echo "foo" > /tmp/test
zed_notify_email "Test notification" /tmp/test
zed_notify_email "Test no body" /dev/null
zed_notify_email "" /tmp/test
rm /tmp/test |
Yeah, code-wise that's fine. I'm not sure what the point of the comments is, though, since they're all, almost literally # echo subject header
echo "Subject: $subject" and they make up 90% of the diff |
@nabijaczleweli the point of the comments is to serve as alternative or addition to the actual code to describe what's going on to everybody, even those who don't instantly recognize what the code is doing. The section you cited was already changed in the current diff. I agree that this was a superflous comment.
I could optimize the diff for size but I'd abstain from that as they don't impose a lot of cost. Although I'd welcome anyone to remove them if they don't fit the general style and wouldn't insist on them. |
@heeplr yes, please squash the commits. |
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Signed-off-by: Daniel Hiepler <d-git@coderdu.de>
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes #13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Some minimal MUAs don't support passing the subjects as cmdline option. This commit checks if "@subject@" is missing in ZED_EMAIL_OPTS and then prepends a subject header to the notification message. Also set a default for ${subject}. Reviewed-by: Ahelenia Ziemia<C5><84>ska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Daniel Hiepler <d-git@coderdu.de> Closes openzfs#13440
Motivation and Context
Setting e-mail subject via ZED_EMAIL_OPTS doesn't always work. Small/lightweight MUAs (e.g. ssmtp) need a "Subject: ..." header in the mail body.
Description
If no
@SUBJECT@
placeholder is found in ZED_EMAIL_OPTS, the notification file will be prepended with a subject header.How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.