3 Replies Latest reply on May 31, 2018 8:35 AM by 2672202

    lex -V / --version

    2672202

      $ /usr/bin/lex -V

      $ /usr/bin/lex --version

      seems to be waiting for input from stdin.

       

      Is this the expected behavior ?

      Exiting with status 0 may be natural.

        • 1. Re: lex -V / --version
          Ali Bahrami-Oracle

          I agree with you that exit(0) would be better behavior. However, lex is behaving as intended. It's a concious backward compatibilty choice. The behavior you note with lex -V is historical: The oldest machine I have access to at the moment is Solaris 10, and 'lex -V' blocks on stdin just as shown above. I'm confident that goes back all the way to Solaris 2.0, and to New Jersey (AT&T) before that.

           

          I added --version as part of Solaris 11.4, as part of a general cleanup of utilities in this area (primarily the linkers):

           

              PSARC/2017/216 SGS -?/--help and -V/--version

              15773520 SUNBT7146316 version output from many sgs utilities could be more useful

           

          Most of the utilities handle this as you suggest, printing the output and exiting without an error. However, with lex, I felt that the existing behavior of 'lex -V' could not be safely changed. I didn't want to take the risk of breaking someone's ancient Makefile containing a call to lex that prints its version, and also generates a lexical analyzer. I'm not thrilled about this, but we decided not to knowingly risk breaking existing build systems.

           

          --version is new, so it could have behaved as you suggest. The problem there is one of consistency. --version is an alias for -V, so having them behave differently would have also been confusing and unsatisfying.

           

          Thank you for noticing, and for taking the time to report it. I appreciate the opportunity to explain.

          • 2. Re: lex -V / --version
            Ali Bahrami-Oracle

            I realize that I could have been a bit more clear. The lex manpage says this about the file operand:

             

                A  pathname  of  an  input  file. If more than one such file is specified, all files is

                concatenated to produce  a  single  lex program.  If no file operands are

               specified, or if a file operand is -, the standard input is used.

             

            This is true even when the -V/--version options are used. Hence the concern for not breaking existing scripts or makefiles that might be adding -V to a request for real work.

            • 3. Re: lex -V / --version
              2672202

              Thank you for your explanation.

               

              I understand the behavior and

              why it is mentioned in man page,

              "immediately exit" only for '-?' and '--help'.