Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

426 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */

/**
 * Quote one argument for a POSIX shell command.
 *
 * Mirrors Python's `shlex.quote` so copied commands cannot interpret argument
 * contents as shell syntax.
 */
export function shellQuote(value: string): string {
  if (value === "") {
    return "''";
  }
  if (/^[\w@%+=:,./-]+$/.test(value)) {
    return value;
  }
  return `'${value.replaceAll("'", `'"'"'`)}'`;
}