diff options
author | P. J. McDermott <pjm@nac.net> | 2012-08-02 07:30:17 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-08-02 07:30:17 (EDT) |
commit | c4d045b597703ec53f56c6397d2e1f58f960ff41 (patch) | |
tree | 1950259c1eb9bd12908a3caf1c4395ab70d4c56f | |
parent | 3917992a7d78cb1a08c01a067560391d6bba005a (diff) |
Prevent field splitting on usage and help strings.
-rw-r--r-- | lib/messages.sh | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/messages.sh b/lib/messages.sh index 597ceaf..ab1533b 100644 --- a/lib/messages.sh +++ b/lib/messages.sh @@ -54,22 +54,34 @@ oh_info() oh_usage() { _util="$(echo "${0##*/}" | sed 's/-/_/g')" + + # Prevent field splitting in the evaluated echo command. + _old_ifs="${IFS}" + IFS= _usage_str="$(eval echo \$\{oh_str_usage_"${_util}"\})" + IFS="${_old_ifs}" + : "${_usage_str:=${oh_str_usage_none}}" printf '%s\n' "${_usage_str}" } oh_help() { - oh_usage _util="$(echo "${0##*/}" | sed 's/-/_/g')" + + # Prevent field splitting in the evaluated echo command. + _old_ifs="${IFS}" + IFS= _help_str="$(eval echo \$\{oh_str_help_"${_util}"\})" + IFS="${_old_ifs}" : "${_help_str:=${oh_str_help_none}}" + + oh_usage printf '%s\n' "${_help_str}" } oh_version() { printf "${oh_str_version}\n" \ - "${0##*/}" '@@package_name@@' '@@package_version@@' + "${0##*/}" '@@PACKAGE_NAME@@' '@@PACKAGE_VERSION@@' } |