yacc -V: return code 1; lex -V: expects input on stdin
openindiana:~$ uname -a SunOS openindiana 5.11 illumos-549e0fd315 i86pc i386 i86pc illumos openindiana:~$ yacc -V; echo "yacc returned with code: '$?'" yacc: Software Generation Utilities (SGU) Solaris-ELF (4.0) command line: fatal: cannot open input file yacc returned with code: '1' openindiana:~$ lex -V lex: Software Generation Utilities (SGU) Solaris-ELF (4.0) ^C openindiana:~$ echo $? 130 openindiana:~$
yacc seems to expect an input file when invoked with the -V (show version) option. Thus it exits with return code 1 instead of 0 and prints a redundant error message. This breaks certain scripts (e.g. cmake) that depend on the return code to determine whether a command is working. lex on the other hand just prints the version and proceeds with reading from stdin, making it necessary to cancel it.
Something like this:
$ yacc -V; echo "yacc returned with code: '$?'" yacc - 1.9 20130304 yacc returned with code: '0' $ lex -V; echo "Return code: '$?'" lex 2.5.37 Return code: '0' $
I'm pretty sure, few people expect any command being invoked with a flag to show its version to actually do anything else besides just showing the version.