Skip to content

Instantly share code, notes, and snippets.

@sevein
Created March 31, 2013 18:20
Show Gist options
  • Save sevein/5281509 to your computer and use it in GitHub Desktop.
Save sevein/5281509 to your computer and use it in GitHub Desktop.
import shlex
s = "name=peanut priv=with\_underscore.*:ALL"
# Ansible method
print shlex.split(s)
# Trying something different
lex = shlex.shlex(s, posix=True)
lex.whitespace_split = True
# lex.wordchars += '\\'
# lex.escape = '\\'
print list(lex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment