Created
September 17, 2021 17:00
-
-
Save evanrrees/ba0cbafbbd85bca2f445cd5fb272589c to your computer and use it in GitHub Desktop.
Unsubscribe from lyrist listserv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Evan Rees | |
# [email protected] | |
# 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