Using Floating Points In Bash Script
<p>I have this Bash script that has a basic <code>if...else</code> operator but the script doesn't seem to recognise the values correctly, and just continues the script, when it should stop and show an error.</p>

<p>I believe it's because I am using a float number, and bash can't tell. Here's the script:</p>

<p><strong><em>Note: the <code>error</code> function is just a customer function</em></strong></p>

<pre><code>while getopts ":mh" opt; do
    case $opt in
        m)
            version="${OPTARG}"
            ;;
        \?)
            error "-$OPTARG is not a valid option. Use '-h' for more options" 'warn'
            ;;
        *|h)
            usage
            ;;
    esac
done
echo ${version} # here for debugging - this is either blank, or '0'
shift $((OPTIND-1))

[[ -z ${version} ]] &amp;&amp; version=5.7

[[ "${version}" -lt "5.5" || "${version}" -gt "5.7" ]] &amp;&amp;
    error "Valid MySQL versions: 5.5 - 5.6 - 5.7" 'error'
echo ${version} # this then becomes '5.7' further down the script
</code></pre>

<p>So obviously I want the script to exit if the value of <code>-m</code> is less than 5.5 or greater than 5.7. Again I think it's to do with the value being a float.</p>

<p>Any help is appreciated.</p>