If he doesn't know anything about scripting, the difficult part is going to be the argument parsing. The rest is trivial, just look at the man page of the mail tool and find how to send a mail from the command line, then paste that into the script. Since the script is not gonna rely on the order of the parameters it's not that trivial.
What I do on these cases is to parse all the parameters in case statement inside a loop. On each round, I check if the parameter is one of the valid switches, then the next parameter will be the argument to that flag (the subject, the attachment, or whatever). On each round, I use the "shift" command to shift the parameter list to the left, hence $2 becomes $1. And repeat until $# is zero.
Untested example:
Code:
#!/bin/bash
function die() {
echo "Aborting."
echo "Reason: \"$1\""
exit 1
}
while [ "$#" -ne "0" ]; do
case "$1" in
-s|--subject)
shift # $2 becomes $1
if [ -n "$1" ]; then
SUBJECT="$1"
shift # yet another shift
else
die "Incorrect syntax."
fi
;;
-a|--attach)
shift # $2 becomes $1
if [ -r "$1" ]; then
ATTACH="$1"
shift # yet another shift
else
die "Incorrect syntax or couldn't read the file to attach."
fi
;;
*)
echo "This is useless: \"$1\""
shift
esac
done
echo "The subject is: \"$SUBJECT\""
echo "I will attach this file: \"$ATTACH\""
I shouldn't provide so explicit examples, but well, I guess I am feeling well today, and anyway you have quite a few things to study and understand there if you are new to shell scripting