Skip to content

Conversation

@asottile
Copy link
Contributor

@asottile asottile commented Jun 1, 2020

  • this isn't quite perfect, for example a node environment containaing a
    single quote character will still produce problems. but this is an
    improvement
  • a more thorough approach would be to use shlex.quote -- however I'm not
    100% certain how that would interact with other shells and particularly
    windows

Resolves pre-commit/pre-commit#1483

@ekalinin
Copy link
Owner

ekalinin commented Jun 2, 2020

Thanks for the patch, @asottile !

But we have a problem for python 2.7:

AttributeError: 'module' object has no attribute 'quote'

From here: https://travis-ci.org/github/ekalinin/nodeenv/jobs/693637385

Yeah, i know that python 2.7 is EOL, but i believe a lot of people still use it.

@ekalinin
Copy link
Owner

ekalinin commented Jun 2, 2020

What about:

try:
    from shlex import quote
except ImportError:
    from pipes import quote

?

@asottile
Copy link
Contributor Author

asottile commented Jun 2, 2020

oh! yeah I'll just pipes.quotes -- forgot about ye olde python 2 :)

- this isn't quite perfect, for example a node environment containaing a
  single quote character will still produce problems.  but this is an
  improvement
- a more thorough approach would be to use `shlex.quote` -- however I'm not
  100% certain how that would interact with other shells and particularly
  windows
@ekalinin ekalinin merged commit 92ac5f3 into ekalinin:master Jun 2, 2020
@asottile asottile deleted the improve_quoting branch June 2, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

syntax error near unexpected token `(' when running a node-based plugin

2 participants