The list of commands inside the braces for the compound command must be terminated by either a semicolon or a newline; the closing brace itself is not sufficient.
Either use
usagearg() {
echo "You're missing an argument on the command line!" >&2; }
or
usagearg() {
echo "You're missing an argument on the command line!" >&2
}
As written, your code treats the right brace as simply another character, and part of the output redirection since there is no intervening whitespace.
As to why this is necessary, you have to go back to how bash
defines certain characters. There is the set of metacharacters, which can separate words when unquoted. There is also the set of control operators, which are vaguely defined as performing a "control function". The right brace }
is in neither category. (Why? I'm not sure, but I think it's related to the use of braces in parameter expansion (${foo}
) which preclude it having otherwise special handling.)