INNER CODE UNIT · Python

shell_quote

torognes/vsearch · completion/scripts/gen_bash.py:55

def shell_quote(s: str) -> str:
    """Quote a string for use inside bash double quotes."""
    return s.replace("\\", "\\\\").replace('"', '\\"').replace("`", "\\`").replace("$", "\\$")


def fmt_pipe(words: list[str]) -> str:
    return "|".join(words)


def main() -> None:
    s = spec_mod.load()

    # Group value-taking options by what their argument completion looks like.
    enum_groups: dict[str, list[str]] = defaultdict(list)   # enum_key -> [opt_name]
    file_groups: dict[str | None, list[str]] = defaultdict(list)  # ftype (or None) -> [opt_name]
    outfile_opts: list[str] = []
    novalue_opts: list[str] = []   # int/real/string/int_list/real_list

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…