def arg_split(s, posix=False, strict=True):
 lex = shlex.shlex(s, posix=posix)
 lex.whitespace_split = True
 lex.commenters = ''
 tokens = []
 while True:
  try:
   tokens.append(next(lex))
  except StopIteration:
   break
  except ValueError:
   if strict:
    raise
   tokens.append(lex.token)
   break
 return tokens

def arg_split ( s , posix = False , strict = True ) : lex = shlex . shlex ( s , posix = posix ) lex . whitespace_split = True lex . commenters = '' tokens = [ ] while True : try : tokens . append ( next ( lex ) ) except StopIteration : break except ValueError : if strict : raise tokens . append ( lex . token ) break return tokens
split a command lines arguments in a shell-like manner .