I’m writing a BASH installer script for a program the requires Flex and Bison version 2.5 or higher.
I’ve already got the code to check that flex and bison are installed at all.
I’m not sure if this has stayed constant throughout the versions but here are the outputs of flex --version and bison --version respectively:
➜ ~ flex --version
flex 2.5.35
➜ ~ bison --version
bison (GNU Bison) 2.5
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Is there a “right” way to check to make sure that the system has flex and bison 2.5 or higher?
Since bash doesn’t handle floating point numbers, you can do the actual comparison in awk.
In order to get this to work in pure bash, each number needs to be compared individually: