I purchased a new Amanda Furnace in Oct'2013. I am told in order to maximize a warm, consistent room temperature I should set the thermostat to the Fan position rather than the Auto position.  Does this make a difference in maintaining room temperature and is it more costly?


Question: getopt, getopts or manual parsing - what to use when I want to support both short and long options?
Answer: getopt vs getopts seems to be a religious issue. As for the arguments against getopt in the Bash FAQ:


"getopt cannot handle empty arguments strings" seems to refer to a known issue with optional arguments, which it looks like getopts doesn't support at all (at least from reading help getopts for Bash 4.2.24). From man getopt:


  getopt(3) can parse long options with optional arguments that are given an empty optional argument (but can not do this for short options). This getopt(1) treats optional arguments that are empty as if they were not present.



I don't know where the "getopt cannot handle [...] arguments with embedded whitespace" comes from, but let's test it:


test.sh:

#!/usr/bin/env bash
set -o errexit -o noclobber -o nounset -o pipefail
params="$(getopt -o ab:c -l alpha,bravo:,charlie --name "$0" -- "$@")"
eval set -- "$params"

while true
do
    case "$1" in
        -a|--alpha)
            echo alpha
            shift
            ;;
        -b|--bravo)
            echo "bravo=$2"
            shift 2
            ;;
        -c|--charlie)
            echo charlie
            shift
            ;;
        --)
            shift
            break
            ;;
        *)
            echo "Not implemented: $1" &gt;&amp;2
            exit 1
            ;;
    esac
done

run:

$ ./test.sh -
$ ./test.sh -acb '   whitespace   FTW   '
alpha
charlie
bravo=   whitespace   FTW   
$ ./test.sh -ab '' -c
alpha
bravo=
charlie
$ ./test.sh --alpha --bravo '   whitespace   FTW   ' --charlie
alpha
bravo=   whitespace   FTW   
charlie



Looks like check and mate to me, but I'm sure someone will show how I completely misunderstood the sentence. Of course the portability issue still stands; you'll have to decide how much time is worth investing in platforms with an older or no Bash available. My own tip is to use the YAGNI and KISS guidelines - Only develop for those specific platforms which you know are going to be used. Shell code portability generally goes to 100% as development time goes to infinity.