Implement get_shell_type with tests

The function already existed in the coala.Shell module, and can be directly used.

def get_shell_type():
    """
    Finds the current shell type based on the outputs of common pre-defined
    variables in them. This is useful to identify which sort of escaping
    is required for strings.

    :return: The shell type. This can be either "powershell" if Windows
             Powershell is detected, "cmd" if command prompt is been
             detected or "sh" if it's neither of these.
    """
    out = run_shell_command('echo $host.name', shell=True)[0]
    if out.strip() == 'ConsoleHost':
        return 'powershell'
    out = run_shell_command('echo $0', shell=True)[0]
    if out.strip() == '$0':
        return 'cmd'
    return 'sh'

But this function wasn't covered by any tests, to implement it here in coala-utils we need some tests.

Assignee Loading
Time tracking Loading