Skip to content
Skillv1.0.0

shell-quoting-ssh

Shell quoting patterns for SSH remote commands and bash tool invocations. Work on first try, not third. Covers single-quote nesting, heredoc alternatives, and common escaping pitfalls.

by aliatx2017(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from aliatx2017/reasonix-hermes (.reasonix/skills/shell-quoting-ssh/SKILL.md). Install upstream with npx skills add aliatx2017/reasonix-hermes --skill shell-quoting-ssh. Copyright stays with the author.

Shell Quoting Patterns

When to Use

  • Running bash tool with complex commands containing quotes, variables, or special chars
  • Executing commands over SSH where quoting nests multiple times
  • Debugging shell quoting errors ("unexpected token", "command not found" where it should work)

Fundamental Rules

  1. Single quotes — everything literal, no expansion. '$HOME' → literal $HOME
  2. Double quotes — variables and $() expand. "$HOME"/Users/alex
  3. No quotes — word splitting + glob expansion. Almost never what you want.

Single Quote Nesting

You CANNOT nest single quotes directly. 'it's' fails. Workarounds:

# End single-quote, insert escaped quote, resume single-quote
echo 'it'"'"'s working'

# Or use double quotes (if no $variables to protect)
echo "it's working"

# Or use heredoc (best for multi-line)
cat <<'EOF'
it's working
EOF

SSH Quoting — Triple Nesting

SSH adds one level of quoting. Complex commands need careful nesting:

# WRONG — inner quotes break
ssh host "grep 'pattern' file"

# RIGHT — outer double, inner single
ssh host "grep 'pattern' file"

# HARD — command with both quote types
# Use heredoc to avoid nightmare quoting
ssh host <<'ENDSSH'
  grep "it's done" /var/log/*.log
ENDSSH

# OR base64-encode the command
CMD=$(echo 'grep "pattern" file' | base64)
ssh host "echo $CMD | base64 -d | bash"

Common Pitfalls

Pattern Wrong Right
Variable in single quotes '$HOME/path' "$HOME/path"
Nested single quotes 'it's' 'it'"'"'s'
Backticks in quotes '`cmd`' "$(cmd)"
Exclamation in double quotes "hello!" 'hello!' or "hello"\!"

bash Tool Specific

The bash tool in Reasonix runs commands via a configured shell. Prefer heredocs for multi-line scripts:

cat <<'SCRIPT' > /tmp/script.sh
#!/bin/bash
# complex logic here
SCRIPT
bash /tmp/script.sh

Verification

After any SSH or complex bash command, verify the output is what you expect. A silent success with no output ≠ it worked.

Related

  • Project skill: ready-means-tested — verify, don't assume
  • Tool: bash — runs commands through configured shell interpreter

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/aliatx2017-reasonix-hermes-shell-quoting-ssh/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

aliatx2017-reasonix-hermes-shell-quoting-ssh.ocm.jsonjson
{
  "ocm": "1",
  "id": "aliatx2017-reasonix-hermes-shell-quoting-ssh",
  "kind": "skill",
  "name": "shell-quoting-ssh",
  "description": "Shell quoting patterns for SSH remote commands and bash tool invocations. Work on first try, not third. Covers single-quote nesting, heredoc alternatives, and common escaping pitfalls.",
  "publisher": "aliatx2017",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "shell",
      "bash",
      "ssh",
      "quoting",
      "escaping",
      "tool-use",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Shell quoting patterns for SSH remote commands and bash tool invocations. Work on first try, not third. Covers single-quote nesting, heredoc alternatives, and common escaping pitfalls."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/aliatx2017/reasonix-hermes",
      "path": ".reasonix/skills/shell-quoting-ssh/SKILL.md",
      "ref": "6a84f83f13bc5026bd285ee9b57f7d98271199a4",
      "url": "https://github.com/aliatx2017/reasonix-hermes/blob/6a84f83f13bc5026bd285ee9b57f7d98271199a4/.reasonix/skills/shell-quoting-ssh/SKILL.md",
      "key": "aliatx2017/reasonix-hermes/.reasonix/skills/shell-quoting-ssh/SKILL.md"
    }
  },
  "instructions": "# Shell Quoting Patterns\n\n## When to Use\n\n- Running `bash` tool with complex commands containing quotes, variables, or special chars\n- Executing commands over SSH where quoting nests multiple times\n- Debugging shell quoting errors (\"unexpected token\", \"command not found\" where it should work)\n\n## Fundamental Rules\n\n1. **Single quotes** — everything literal, no expansion. `'$HOME'` → literal `$HOME`\n2. **Double quotes** — variables and `$()` expand. `\"$HOME\"` → `/Users/alex`\n3. **No quotes** — word splitting + glob expansion. Almost never what you want.\n\n## Single Quote Nesting\n\nYou CANNOT nest",
  "cost": {
    "context_tokens": 558
  }
}

Fetch it by URL: GET /api/v1/registry/aliatx2017-reasonix-hermes-shell-quoting-ssh/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.