Surely you should also check for dash here.
If --M gets added as an option, meaning something different than -M, you'd be caught out here !