gentoo/gentoo-functions — pull request #1 by dywisor (2014-09-22 19:53:33+00:00)
Title: consider adding support for "set -o nounset"

The patch attached to this pull-req introduces three changes:

* add support for using gentoo-functions in scripts that use nounset (``set -u``)
* more robust usage of ``shift`` (dash screams when trying to shift non-existent args)
* use ``unset -v`` instead of ``unset`` so that there's no chance to unset functions (though unlikely)

--- commit message ---
```
default some vars to if unset:
* optional args in eindent(), eoutdent()
* also $1 in yesno()
* CONF_LIBDIR_OVERRIDE -- function would crash the script otherwise
* CONSOLETYPE -- file would not load properly otherwise
* EINFO_LOG -- unsure, but defaulting doesn't hurt
* EINFO_QUIET -- ^
* EINFO_VERBOSE -- ^
* LAST_E_CMD -- ^
* RC_ENDCOL -- ^
* RC_INDENTATION -- ^
* RC_NOCOLOR -- ^

vars left unchanged:
* BAD -- "always set"
* BRACKED -- ^
* COLS -- ^
* COLUMNS -- n/a, has default value
* CONF_LIBDIR -- has default
* ENDCOL -- "always set"
* GOOD -- ^
* NORMAL -- ^
* RC_DEFAULT_INDENT -- not interested in hardcoding ${RC_DEFAULT_INDENT:-2}
* WARN -- "always set"

Other changes:

* in functions that shift N args and access $* afterwards:
immediately return if shift fails: shift N || return
or make shift optional: [ $# -eq 0 ] || shift (for N=1)

* use "unset -v" (don't try to unset functions)
```