INNER CODE UNIT · Python

arg_desc

torognes/vsearch · completion/scripts/gen_zsh.py:25

def arg_desc(s: str) -> str:
    """Escape characters that have meaning inside an `_arguments` `[...]`
    description bracket. Shell quoting is handled separately by sh_squote."""
    return (
        s.replace("\\", "\\\\")
         .replace("[", "\\[")
         .replace("]", "\\]")
         .replace(":", "\\:")
    )


def sh_squote(s: str) -> str:
    """Wrap a string in single quotes, escaping embedded single quotes."""
    return "'" + s.replace("'", "'\\''") + "'"


def file_glob(extensions: list[str]) -> str:
    return "*.(" + "|".join(extensions) + ")"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…