Copy button audit %

Every [source,shell] and [source,console] block in the FreeBSD documentation, run through copy-clipboard.js. On the left, what the document shows; on the right, what the copy button puts on the clipboard. Struck-through lines are command output and are dropped on purpose. Asciidoctor callouts (<1>) are markup rather than code, so they are dropped as well.

Known limitations — cases the heuristic cannot decide, to be fixed in the documents

# is both the root prompt and the shell comment character, and it also opens comments in several output formats. # pkg search zip and # search result have exactly the same shape, so no heuristic separates them. Two residual classes are left, and both are cheaper to fix in the document than in the script:

A root command dropped inside a % session

Within a block that already uses %, a # line only counts as a root prompt if the block runs su or sudo. Two real occurrences in the whole corpus:

  • en/books/accessibility/colors/_index.adoc:149# pkg search zip
  • en/books/accessibility/colors/_index.adoc:588# sysctl hw.acpi.video.lcd0.brightness=50

The other 19 lines dropped by this rule are LDIF output or prose comments, so dropping them is correct.

Output that starts with the prompt character

Three sources, 20 blocks across all languages:

  • ldapsearch — LDIF comments with #: books/handbook/network-servers (en:1562, plus de, pl, pt-br, zh-tw)
  • gbde init — the editor template is commented with #: books/handbook/disks (en:1798, plus 12 translations)
  • strings ….pfb — PostScript comments with %: articles/fonts (en:206, ja:177)

In both classes the fix is the one the FDP Primer already recommends: keep the command in [source,shell] and put the output in a plain literal block.