parameters: (argument)
return_statement: return encoded
docstring: Encodes |argument| suitably for consumption by POSIX shells.
  
    argument may be quoted and escaped as necessary to ensure that POSIX shells
    treat the returned value as a literal representing the argument passed to
    this function.  Parameter (variable) expansions beginning with $ are allowed
    to remain intact without escaping the $, to allow the argument to contain
    references to variables to be expanded by the shell.
docstring_summary: Encodes |argument| suitably for consumption by POSIX shells.
docstring_tokens: Encodes |argument| suitably for consumption by POSIX shells .
function: def EncodePOSIXShellArgument(argument):
    """Encodes |argument| suitably for consumption by POSIX shells.
  
    argument may be quoted and escaped as necessary to ensure that POSIX shells
    treat the returned value as a literal representing the argument passed to
    this function.  Parameter (variable) expansions beginning with $ are allowed
    to remain intact without escaping the $, to allow the argument to contain
    references to variables to be expanded by the shell.
    """
  
    if not isinstance(argument, str):
      argument = str(argument)
  
    if _quote.search(argument):
      quote = '"'
    else:
      quote = ''
  
    encoded = quote + re.sub(_escape, r'\\\1', argument) + quote
  
    return encoded
function_tokens: def EncodePOSIXShellArgument ( argument ) : if not isinstance ( argument , str ) : argument = str ( argument ) if _quote . search ( argument ) : quote = '"' else : quote = '' encoded = quote + re . sub ( _escape , r'\\\1' , argument ) + quote return encoded