#!/bin/sh -efu
# This file is covered by the GNU General Public License,
# which should be included with libshell as the file LICENSE.
# All copyright information are listed in the COPYING.

if [ -z "${__included_shell_string-}" ]; then
__included_shell_string=1

# Creates a mask of equal length string.
# Usage: fill_mask var str [full-length]
fill_mask() {
	local __i=0 __m= __v="$1" __s="$2"
	while [ $__i -lt ${#__s} ]; do
		__m="$__m?????"
		__i=$(($__i + 5))
	done
	case $((${#__m} - ${#__s})) in
		5) __m="${__m#?????}" ;;
		4) __m="${__m#????}" ;;
		3) __m="${__m#???}" ;;
		2) __m="${__m#??}" ;;
		1) __m="${__m#?}" ;;
	esac
	[ -n "${3-}" ] || __m="${__m#?}"
	eval "$__v=\$__m"
}

fi #__included_shell_string
