

def _shell_join(seq):
    '\n    Convert a nested list of strings to a shell command.\n\n    Each string in the list is escaped as necessary to allow it to be\n    passed to a shell as a single word. If an item is a list, it is a\n    nested command, which will be escaped first, and then added as a\n    single word to the top-level command.\n\n    For example, [\'su\', \'root\', \'-c\', [\'apt-get\', \'update\']] becomes\n    "su root -c \'apt-get update\'".\n    '
    result = []
    for word in seq:
        if isinstance(word, (tuple, MutableSequence)):
            word = _shell_join(word)
        escaped = shell_quote(word)
        result.append(escaped)
    return ' '.join(result)

dataset/ETHPy150Open ClusterHQ/flocker/flocker/provision/_ssh/_model.py _shell_join/original