<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expandvars(s, vars=None):
 """Perform variable substitution on the given string Supported syntax: * $VARIABLE * ${VARIABLE} * ${#VARIABLE} * ${VARIABLE:-default} :param s: message to expand :type s: str :param vars: dictionary of variables. Default is ``os.environ`` :type vars: dict :return: expanded string :rtype: str """

    tpl = TemplateWithDefaults(s)
    return tpl.substitute(vars or os.environ)