# Shell argv quote

`shell-argv-quote` · version 1.0.0 · Developer tools · free, no key needed

Quote inert argv strings for POSIX sh or PowerShell 7, returning a command and its per-argument fragments.

**Use when you need to: quote argv for POSIX shell · escape command arguments for sh · quote argv for PowerShell 7.**

## Decide before calling

Read the [versioned contract](/v1/tools/shell-argv-quote/versions/1.0.0) and the supported scope below. Reuse `shell-argv-quote@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `shell-argv-quote@1.0.0` for quote argv for POSIX shell. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- quote argv for POSIX shell
- escape command arguments for sh
- quote argv for PowerShell 7
- build a shell command string safely
- preserve empty shell arguments
- render command line arguments

## Not supported

- execute or launch a shell command
- parse a command string into arguments
- quote for cmd.exe or non-POSIX shells

## Behavior

- Input strings are inert data; the tool never starts or invokes a shell.
- posix-sh wraps every argument in single quotes; an embedded apostrophe becomes the adjacent quoted fragments ' followed by "'" followed by '.
- powershell-7 wraps every argument in single quotes and represents an embedded apostrophe by two apostrophes.
- Empty argv returns an empty command and empty fragments; otherwise command joins fragments with one ASCII space.
- NUL and lone surrogate code units are rejected with invalid_input; byte and item caps return limit_exceeded.

## Input

- `profile` (one of "posix-sh", "powershell-7", required)
- `argv` (array of string, required): max items 128; each max length 4096

## Output

- `command` (string, required): max length 32768
- `fragments` (array of string, required): max items 128; each max length 20482

## Limits

- max arguments: 128
- max argument bytes: 4096
- max total input bytes: 16384
- max output bytes: 32768

## Example

Request input:

```json
{
  "profile": "posix-sh",
  "argv": [
    "printf",
    "%s\\n",
    "it's ready",
    ""
  ]
}
```

Response:

```json
{
  "result": {
    "command": "'printf' '%s\\n' 'it'\"'\"'s ready' ''",
    "fragments": [
      "'printf'",
      "'%s\\n'",
      "'it'\"'\"'s ready'",
      "''"
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "shell-argv-quote",
  "version": "1.0.0",
  "input": {
    "profile": "posix-sh",
    "argv": [
      "printf",
      "%s\\n",
      "it's ready",
      ""
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/shell-argv-quote/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"profile":"posix-sh","argv":["printf","%s\\n","it'\''s ready",""]}'
```

The machine-readable contract is at [/v1/tools/shell-argv-quote/versions/1.0.0](/v1/tools/shell-argv-quote/versions/1.0.0).

### CLI

```sh
node cli.mjs run shell-argv-quote 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Editorconfig resolve](/tools/editorconfig-resolve): Resolve EditorConfig properties for one normalized relative POSIX path from caller-supplied file contents.
- [Chmod mode convert](/tools/chmod-mode-convert): Convert a Unix permission mode and apply explicit chmod symbolic clauses, returning canonical octal and symbolic forms.
- [Commit conventional parse](/tools/commit-conventional-parse): Parse one Conventional Commits 1.0.0 message into its header, body, footers, and breaking-change status.
- [Openapi operation extract](/tools/openapi-operation-extract): Extract one OpenAPI operation, merge inherited parameters, and return its local component-reference closure.
- [Sql statements split](/tools/sql-statements-split): Split SQL text into exact statement spans with explicit PostgreSQL, MySQL, or SQLite lexical rules.
- [Tap output parse](/tools/tap-output-parse): Parse TAP version 13 text into ordered assertions, plan validity, diagnostics, directives, and bailout state.
