(s)
return "'" + s.replace("'", "'\"'\"'") + "'"
Escape a string with single quotes in order to be parsed as a single element by shlex

    Parameters
    ----------
    s : str
        The string to quote

    Returns
    -------
    str
       The quoted string
Escape a string with single quotes in order to be parsed as a single element by shlex
Escape a string with single quotes in order to be parsed as a single element by shlex
def single_quote(s):
    """Escape a string with single quotes in order to be parsed as a single element by shlex

    Parameters
    ----------
    s : str
        The string to quote

    Returns
    -------
    str
       The quoted string
    """
    if not s:
        return "''"
    if find_unsafe(s) is None:
        return s

    # use single quotes, and put single quotes into double quotes
    # the string $'b is then quoted as '$'"'"'b'
    return "'" + s.replace("'", "'\"'\"'") + "'"
def single_quote ( s ) : if not s : return "''" if find_unsafe ( s ) is None : return s # use single quotes, and put single quotes into double quotes # the string $'b is then quoted as '$'"'"'b' return "'" + s . replace ( "'" , "'\"'\"'" ) + "'"