diff --git a/hosts b/hosts index 3ab547a..1a01b54 100755 --- a/hosts +++ b/hosts @@ -27,103 +27,10 @@ # Strict Mode ############################################################################### -# Treat unset variables and parameters other than the special parameters ‘@’ or -# ‘*’ as an error when performing parameter expansion. An 'unbound variable' -# error message will be written to the standard error, and a non-interactive -# shell will exit. -# -# This requires using parameter expansion to test for unset variables. -# -# http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion -# -# The two approaches that are probably the most appropriate are: -# -# ${parameter:-word} -# If parameter is unset or null, the expansion of word is substituted. -# Otherwise, the value of parameter is substituted. In other words, "word" -# acts as a default value when the value of "$parameter" is blank. If "word" -# is not present, then the default is blank (essentially an empty string). -# -# ${parameter:?word} -# If parameter is null or unset, the expansion of word (or a message to that -# effect if word is not present) is written to the standard error and the -# shell, if it is not interactive, exits. Otherwise, the value of parameter -# is substituted. -# -# Examples -# ======== -# -# Arrays: -# -# ${some_array[@]:-} # blank default value -# ${some_array[*]:-} # blank default value -# ${some_array[0]:-} # blank default value -# ${some_array[0]:-default_value} # default value: the string 'default_value' -# -# Positional variables: -# -# ${1:-alternative} # default value: the string 'alternative' -# ${2:-} # blank default value -# -# With an error message: -# -# ${1:?'error message'} # exit with 'error message' if variable is unbound -# -# Short form: set -u set -o nounset - -# Exit immediately if a pipeline returns non-zero. -# -# NOTE: this has issues. When using read -rd '' with a heredoc, the exit -# status is non-zero, even though there isn't an error, and this setting -# then causes the script to exit. read -rd '' is synonymous to read -d $'\0', -# which means read until it finds a NUL byte, but it reaches the EOF (end of -# heredoc) without finding one and exits with a 1 status. Therefore, when -# reading from heredocs with set -e, there are three potential solutions: -# -# Solution 1. set +e / set -e again: -# -# set +e -# read -rd '' variable < /dev/null -SAFER_IFS="$(printf '\n\t')" -# Then set $IFS -IFS="$SAFER_IFS" +IFS="$(printf '\n\t')" ############################################################################### # Globals