Comments.

This commit is contained in:
Devin Teske 2013-11-07 10:44:24 +00:00
parent ebee96b642
commit f1d6beba07

View File

@ -46,7 +46,7 @@ VALID_VARNAME_CHARS="0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
############################################################ FUNCTIONS
# f_substr "$string" $start [ $length ]
# f_substr "$string" $start [$length]
#
# Simple wrapper to awk(1)'s `substr' function.
#
@ -56,16 +56,16 @@ f_substr()
echo "$string" | awk "{ print substr(\$0, $start, $len) }"
}
# f_snprintf $var_to_set $size $format ...
# f_snprintf $var_to_set $size $format [$arguments ...]
#
# Similar to snprintf(3), write at most $size number of bytes into $var_to_set
# using printf(1) syntax (`$format ...'). The value of $var_to_set is NULL
# unless at-least one byte is stored from the output.
# using printf(1) syntax (`$format [$arguments ...]'). The value of $var_to_set
# is NULL unless at-least one byte is stored from the output.
#
f_snprintf()
{
local __var_to_set="$1" __size="$2"
shift 2 # var_to_set/size
shift 2 # var_to_set size
eval "$__var_to_set"=\$\( printf \"\$@\" \| awk -v max=\"\$__size\" \''
{
len = length($0)