Skip to content

Incompatible arg quoting in windows #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jacobEAdamson opened this issue Sep 17, 2018 · 0 comments · May be fixed by #808
Open

Incompatible arg quoting in windows #375

jacobEAdamson opened this issue Sep 17, 2018 · 0 comments · May be fixed by #808

Comments

@jacobEAdamson
Copy link

When running command with 1+ arguments against a docker host, the command automatically fails with line 1: syntax error: unterminated quoted string. The is because the quote method in backend/base.py is using pipes.quote (which is only compatible with posix systems) to generate quotes, and sometimes uses single quotes to enclose an arg. The default shell in windows is cmd, which does not accept single quoted args (only double quoted). On windows, a more accurate command would be something like this:

@staticmethod
def quote(command, *args):
    def anon_1(arg):
        if re.match(r'/("|\s|\')', arg) != None:
            return arg

        arg = re.sub('"', '\"', arg)
        return '"%s"' % (arg)

    if args:
        return command % tuple(anon_1(a) for a in args)
        # return command % tuple(pipes.quote(a) for a in args)
    return command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants