Last active
July 22, 2019 13:16
-
-
Save SVilgelm/ea459b4b195cee16c54d882f9f83c020 to your computer and use it in GitHub Desktop.
Shell sanitizing, quoting parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: # py3 | |
| from shlex import quote # noqa | |
| except ImportError: # py2 | |
| from pipes import quote # noqa | |
| def format_cmd(cmd, *args, **kwargs): | |
| return cmd.format(*[quote(str(i)) for i in args], | |
| **{k: quote(str(v)) for k, v in kwargs.items()}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment