def METHOD_NAME(value, unsafe_regex=None, replacements=None,
               enclose_with='"'):
    """Join args into a valid shell command.
    """
    # historic backwards compatibility, unsure why this is here
    if not is_non_string_iterable(value):
        return str(value)
    unsafe_regex = unsafe_regex or _find_unsafe
    def escape_word(s):
        if not s:
            return "''"
        if unsafe_regex(s) is None:
            return s
        for from_, to_ in (replacements or []):
            if isinstance(from_, six.string_types):
                s = s.replace(from_, to_)
            else:
                s = from_.sub(to_, s)  # assume from_ is re.compile
        return enclose_with + s + enclose_with
    return ' '.join(escape_word(x) for x in value)