LuRsT/hr — pull request #15 by markusfisch (2014-02-11 08:57:41+00:00)
Title: More portable, sourceable and less dependencies

#!/usr/bin/env bash is more portable than #!/bin/bash.

Used bash built-in shell variable COLUMNS instead of tput.

Used default values (${VAR:-N}) instead of if-then statement.

Made the script sourceable so it can be used from other scripts.

Made variables local.

Changed environment variables to upper case. Every variable in a bash script is a environment variable which is "global" for all subsequent invocations; see:

foo()
{
echo $FOOBAR
}

bar()
{
local FOOBAR=7
foo
}

To reflect that, a bash variable should be upper case. But YMMV, so it's up to you. Just wanted to explain why some people use upper case.

Moved the ability to process multiple arguments in its own function. This way the tasks are atomized and the environment is not polluted by WORD because it can be local.