import re

_find_unsafe = re.compile(r'[\s<>|&^]').search


def quote_arg(s):
    """Based on shlex.quote in the standard library."""
    if not s:
        return '""'
    if _find_unsafe(s) is None:
        return s

    # If we found an unsafe character, escape with double quotes.
    return '"' + s + '"'

import re

_find_unsafe = re.compile(r'[\s<>|&^]').search


def quote_arg(s):
    """Based on shlex.quote in the standard library."""
    if not s:
        return '""'
    if _find_unsafe(s) is None:
        return s
    if s.startswith('"') and s.endswith('"'):
        return s

    # If we found an unsafe character, escape with double quotes.
    return '"' + s + '"'

Add check for args which are already quotes
Add check for args which are already quotes

  import re
  
  _find_unsafe = re.compile(r'[\s<>|&^]').search
  
  
  def quote_arg(s):
      """Based on shlex.quote in the standard library."""
      if not s:
          return '""'
      if _find_unsafe(s) is None:
          return s
+     if s.startswith('"') and s.endswith('"'):
+         return s
  
      # If we found an unsafe character, escape with double quotes.
      return '"' + s + '"'
  
Add check for args which are already quotes
## Code Before:
import re

_find_unsafe = re.compile(r'[\s<>|&^]').search


def quote_arg(s):
    """Based on shlex.quote in the standard library."""
    if not s:
        return '""'
    if _find_unsafe(s) is None:
        return s

    # If we found an unsafe character, escape with double quotes.
    return '"' + s + '"'

## Instruction:
Add check for args which are already quotes
## Code After:
import re

_find_unsafe = re.compile(r'[\s<>|&^]').search


def quote_arg(s):
    """Based on shlex.quote in the standard library."""
    if not s:
        return '""'
    if _find_unsafe(s) is None:
        return s
    if s.startswith('"') and s.endswith('"'):
        return s

    # If we found an unsafe character, escape with double quotes.
    return '"' + s + '"'
