parameters: (arg, quote_cmd=True)
return_statement: return arg
docstring: Quote a command line argument so that it appears as one argument when
      processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for
      Windows programs).
docstring_summary: Quote a command line argument so that it appears as one argument when
      processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for
      Windows programs).
docstring_tokens: Quote a command line argument so that it appears as one argument when processed via cmd . exe and parsed by CommandLineToArgvW ( as is typical for Windows programs ) .
function: def QuoteForRspFile(arg, quote_cmd=True):
      """Quote a command line argument so that it appears as one argument when
      processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for
      Windows programs)."""
      # See http://goo.gl/cuFbX and http://goo.gl/dhPnp including the comment
      # threads. This is actually the quoting rules for CommandLineToArgvW, not
      # for the shell, because the shell doesn't do anything in Windows. This
      # works more or less because most programs (including the compiler, etc.)
      # use that function to handle command line arguments.
  
      # Use a heuristic to try to find args that are paths, and normalize them
      if arg.find("/") > 0 or arg.count("/") > 1:
          arg = os.path.normpath(arg)
  
      # For a literal quote, CommandLineToArgvW requires 2n+1 backslashes
      # preceding it, and results in n backslashes + the quote. So we substitute
      # in 2* what we match, +1 more, plus the quote.
      if quote_cmd:
          arg = windows_quoter_regex.sub(lambda mo: 2 * mo.group(1) + '\\"', arg)
  
      # %'s also need to be doubled otherwise they're interpreted as batch
      # positional arguments. Also make sure to escape the % so that they're
      # passed literally through escaping so they can be singled to just the
      # original %. Otherwise, trying to pass the literal representation that
      # looks like an environment variable to the shell (e.g. %PATH%) would fail.
      arg = arg.replace("%", "%%")
  
      # These commands are used in rsp files, so no escaping for the shell (via ^)
      # is necessary.
  
      # As a workaround for programs that don't use CommandLineToArgvW, gyp
      # supports msvs_quote_cmd=0, which simply disables all quoting.
      if quote_cmd:
          # Finally, wrap the whole thing in quotes so that the above quote rule
          # applies and whitespace isn't a word break.
          return f'"{arg}"'
  
      return arg
function_tokens: def QuoteForRspFile ( arg , quote_cmd = True ) : # See http://goo.gl/cuFbX and http://goo.gl/dhPnp including the comment # threads. This is actually the quoting rules for CommandLineToArgvW, not # for the shell, because the shell doesn't do anything in Windows. This # works more or less because most programs (including the compiler, etc.) # use that function to handle command line arguments. # Use a heuristic to try to find args that are paths, and normalize them if arg . find ( "/" ) > 0 or arg . count ( "/" ) > 1 : arg = os . path . normpath ( arg ) # For a literal quote, CommandLineToArgvW requires 2n+1 backslashes # preceding it, and results in n backslashes + the quote. So we substitute # in 2* what we match, +1 more, plus the quote. if quote_cmd : arg = windows_quoter_regex . sub ( lambda mo : 2 * mo . group ( 1 ) + '\\"' , arg ) # %'s also need to be doubled otherwise they're interpreted as batch # positional arguments. Also make sure to escape the % so that they're # passed literally through escaping so they can be singled to just the # original %. Otherwise, trying to pass the literal representation that # looks like an environment variable to the shell (e.g. %PATH%) would fail. arg = arg . replace ( "%" , "%%" ) # These commands are used in rsp files, so no escaping for the shell (via ^) # is necessary. # As a workaround for programs that don't use CommandLineToArgvW, gyp # supports msvs_quote_cmd=0, which simply disables all quoting. if quote_cmd : # Finally, wrap the whole thing in quotes so that the above quote rule # applies and whitespace isn't a word break. return f'"{arg}"' return arg