Skip to content

Instantly share code, notes, and snippets.

@evanrrees
Created September 17, 2021 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanrrees/ba0cbafbbd85bca2f445cd5fb272589c to your computer and use it in GitHub Desktop.
Save evanrrees/ba0cbafbbd85bca2f445cd5fb272589c to your computer and use it in GitHub Desktop.
Unsubscribe from lyrist listserv
#!/usr/bin/env bash
# Evan Rees
# err87@cornell.edu
# 13 Sep 2021
# Generate mailto link for joining / leaving Cornell listservs.
# This just wraps the one-liner at the end.
# The link can be opened in any browser or with the macOS `open` command.
declare MAILTO REQUEST
usage() {
cat <<- EOF
Usage:
$0 join LIST
$0 leave LIST
EOF
}
if (( $# == 0 )); then
usage
exit 0
elif [[ $1 =~ ^[-]{0,2}h(elp)?$ ]]; then
usage
exit 0
elif (( $# != 2 )); then
echo "Not enough arguments supplied (expected 2, found $#)" > /dev/stderr
usage
exit 1
elif ! [[ $2 =~ @ ]]; then
echo "Invalid argument to LIST: $2" > /dev/stderr
usage
exit 1
else
case "$1" in
join|j);;
leave|l);;
help|-h|--help) usage; exit 0;;
*)
echo "Unrecognized argument: $1" > /dev/stderr
usage
exit 1
;;
esac
fi
echo "mailto:${2/@/-request@}?subject=$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment