(Since you use it both for -h and for unknown options, perhaps make it not exit at all, and make the caller exit with an appropriate code?)
Additionally, you should output the actual executable name (as passed in on $0) rather than hardcoding something. So maybe at the top say 'executable=$0; shift'; replace parseflags.sh with $executable; and replace $1 with $0 in your option parse loop.
And you can just use $0 everywhere so there's technically no reason to pull it out into a $executable variable, but tbh that gets a bit confusing in functions.
I tried using $0 years ago, but I didn't like seeing the full path name (or the "./parseflags.sh" string), or maybe it was because I often use shell alias, so the $0 becomes the alias name, or something like that. So now, I just replace the string "parseflags.sh" with the name of the script for each script. I think I tried using $(basename $0) at one point, but didn't like that either, though I don't remember why.
I hope that the template is simple enough that people can customize it as they wish.
Edit: Fix typo
echo "message" 1>&2
Yes, that's probably a good idea, though I cannot recall this causing a problem for any script that I've written so far. fancycommand --help | less
works as expected. Otherwise, the help text will dump to the screen and less will erase it when it decides to redraw its empty buffer! Actual error messages should go to stderr so that I can redirect them to an error log or so I can suppress them if need be, or I could also be doing > /dev/stdout to silence normal output but I don't want errors to be discarded. $ tens.sh --verbose 5
10
100
1000
10000
100000
Calculated 5 results
$ tens.sh --verbose 5 > results
Calculated 5 results
Edit: Send error messages to stderr
Edit2: People seem to like it. I created a GitHub gist for it here: https://gist.github.com/bxparks/e67a3d6fc6b5d62b51304b3d9de2...