Fix a shell command copied from chat, docs or a web page

Paste a command that will not run and get it back with straight quotes, real flags and no prompts, plus a heredoc check.

How it works

  1. Paste the command exactly as you copied it
  2. Read the fixed command and the list of changes
  3. Copy the fixed command, or the one-line bash -c form

What this page repairs

Paste a shell command that fails after you copied it and this page puts back the plain characters the shell expects, then shows every change it made. It replaces curly quotes such as “ and ’ with straight ones. It turns an en dash or em dash that starts a flag back into the hyphens it came from: –rm becomes --rm and –m stays a one-letter -m, while a minus sign or look-alike hyphen becomes a single -. It swaps non-breaking spaces for spaces and deletes zero-width characters and bidirectional controls. It removes leading prompts such as $, %, PS C:\>, user@host:~$ and the > shown on continuation lines, removes the spaces after a line-ending backslash that break the continuation, and strips Jupyter's leading ! from !pip.

A worked example

The page opens with a docker command copied from a terminal transcript: $ docker run –rm –name web -p 8080:80 -v “$PWD”:/usr/share/nginx/html nginx:latest, then a heredoc that writes run.sh and whose lines start with a continuation marker. The fixer reports 2 smart quotes, 2 dashes and 5 prompts removed, and the result is docker run --rm --name web -p 8080:80 -v "$PWD":/usr/share/nginx/html nginx:latest followed by the heredoc without its prompts. Text inside quotes and heredoc bodies is data and is left as written: printf '%s\n' '“hi”' keeps its curly quotes and an emoji such as a woman technologist keeps its zero-width joiner. The Checks box lists odd spaces or invisible characters it left inside quotes, and smart quotes found inside a heredoc body.

Wrapped lines and what Guess does

A PDF or a narrow page can wrap one command over several lines, and a real multi-command paste looks the same, so the page keeps your lines by default and never joins on its own. Choose Guess wrapped lines to join two lines when the first is at least 40 characters and ends in /, -, = or :, or is exactly 72, 76, 78, 79 or 80 characters long, or three or more long lines are almost the same length. Guess can join separate commands by mistake, for example echo with a long URL ending in a slash followed by another echo, so read the Changes list, which shows every original line next to its result. Choose Join, no space for a cut in the middle of a word or Join, one space for a wrap at a space. A line that ends in a backslash is a real continuation and is never joined, and neither are comments, heredoc bodies or a line that had a prompt. A paste where every line starts with > is kept unless you turn on the quoted block option, because > file lines are redirections.

Checks, heredocs and the bash -c form

The Checks box warns about quotes, backticks, parentheses, braces and square brackets that never close, a last line ending in a backslash, | or &&, and ! inside double quotes. When the command has a heredoc it also checks each one. An unquoted delimiter such as <<EOF lets the shell expand $VAR, $(...) and backticks in the body, so each expansion is listed with its line number and a version with <<'EOF' is offered. It also reports <<- bodies indented with spaces instead of tabs, a missing or indented terminator, a second line equal to the delimiter after the heredoc ended, and nested heredocs. This is a text check, not a shell parser, and it never runs anything. An agent can open the page with #input= followed by the URL-encoded command.

Frequently asked questions

Why does my copied command say "command not found" or "unknown option"?

Chat apps, word processors and PDFs often turn -- into an en dash or em dash and " into curly quotes. The shell then sees –rm instead of --rm. Paste it here and the dashes before flags and the quotes are replaced, and each change is listed.

How do I find a hidden non-breaking space in a command?

A non-breaking space (U+00A0) looks like a space but is not a word separator, so ls -la fails when the gap is U+00A0. The fixer replaces it and the Changes list shows the original as [NBSP]. Zero-width spaces (U+200B) are deleted and shown as [ZWSP].

Why did the fixer not remove the # at the start of my line?

A line starting with # is a comment in a script, so it is kept by default. Turn on the root prompt option when # apt update in a tutorial means a root prompt, and the # and the space after it are removed.

Why does bash say "!pip: event not found"?

In a notebook !pip install x runs a shell command, but in bash a leading ! starts history expansion. The fixer removes the ! and any spaces before it from a line that starts with ! and a letter, so you get pip install x.

What does an unquoted heredoc delimiter do?

With <<EOF the shell expands $HOME, $(date) and backticks in the body before the command sees it. With <<'EOF' it keeps the text exactly. The checker lists each expansion, for example line 3: $HOME, and gives the quoted version.

Is my command uploaded?

No. The text is processed in your browser and not uploaded, and the command is never run. Your command is not saved; only the option settings are kept on this device.