cli(show): a pipe starts an output modifier, and the port name ends there #2537

Merged
jaylouisw merged 1 commit from rev/1124-0612 into main 2026-11-24 06:38:08 +00:00
Owner

The question

A pipe on a show line: is what stands after it a word of the name on its left, or a filter on the answer?

Verdict

A filter. IOS states the grammar as command | {begin | include | exclude} regular-expression and works the example Device# show interfaces | include protocol (Command Reference, IOS XE 17.12.x, Catalyst 9500, Searching and Filtering Output of show and more Commands; the same section verbatim in the 9200 17.18.x and 2960-X 15.2(7)E books). So the object named before the pipe is complete at the pipe.

This console read the whole rest of the line as a port name:

sw1#show interfaces Port 1 | include packets
% No interface Port 1 | include packets on Cambium cnMatrix EX2010-P-sw1
  • a socket the same command without the pipe prints, reported missing;
  • and the pipe - the one part of the line the console had not understood - never mentioned.

Change

_show() now splits the line at the first | token before any door opens, so every view parses it the same way. Four one-line answers: a known filter word is refused as an output modifier this console does not model (and names the command that prints the whole answer); any other word is refused as not an output modifier, naming begin/include/exclude; a bare pipe (or ?) is % Incomplete command:; and a pipe with no view before it asks for the view. The filter word is compared lowercased like any keyword. No filter is implemented - printing an unfiltered block under a filter would be trusted lines the box had already dropped.

show running-config | include vlan, which had its own sentence for this, now answers the same way as every other view.

Tests

  • test/show-output-filter.test.js - 50 assertions: the four answers, a spaced port name (Port 1) kept whole, the port block unchanged, ?-after-pipe, case-insensitive filter word, and that show interfaces <port> counters is still answered as a view.
  • test/docs-show-commands.test.js 7/7 and test/show-argument-refusal.test.js 97/97 - the doc section added here is typed back by the docs sweep.
  • Full suite before the doc fix: 480 suites, 16,138 assertions, 1 red - the docs sweep reading a doc code span that split on |. Fixed on this branch; that suite re-run is green (7/7).

Docs: docs/CLI.md, new subsection under "A command with words it cannot use refuses them". Evidence and the open edges (glued | with no spaces, ? after a pipe, section) in research/show-output-filter.md.

## The question A pipe on a `show` line: is what stands after it a word of the name on its left, or a filter on the answer? ## Verdict A **filter**. IOS states the grammar as `command | {begin | include | exclude} regular-expression` and works the example `Device# show interfaces | include protocol` (Command Reference, IOS XE 17.12.x, Catalyst 9500, *Searching and Filtering Output of show and more Commands*; the same section verbatim in the 9200 17.18.x and 2960-X 15.2(7)E books). So the object named before the pipe is complete at the pipe. This console read the whole rest of the line as a port name: ``` sw1#show interfaces Port 1 | include packets % No interface Port 1 | include packets on Cambium cnMatrix EX2010-P-sw1 ``` - a socket the same command without the pipe prints, reported missing; - and the pipe - the one part of the line the console had not understood - never mentioned. ## Change `_show()` now splits the line at the first `|` token before any door opens, so every view parses it the same way. Four one-line answers: a known filter word is refused as an output modifier this console does not model (and names the command that prints the whole answer); any other word is refused as not an output modifier, naming `begin`/`include`/`exclude`; a bare pipe (or `?`) is `% Incomplete command:`; and a pipe with no view before it asks for the view. The filter word is compared lowercased like any keyword. No filter is implemented - printing an unfiltered block under a filter would be trusted lines the box had already dropped. `show running-config | include vlan`, which had its own sentence for this, now answers the same way as every other view. ## Tests - `test/show-output-filter.test.js` - 50 assertions: the four answers, a spaced port name (`Port 1`) kept whole, the port block unchanged, `?`-after-pipe, case-insensitive filter word, and that `show interfaces <port> counters` is still answered as a view. - `test/docs-show-commands.test.js` 7/7 and `test/show-argument-refusal.test.js` 97/97 - the doc section added here is typed back by the docs sweep. - Full suite before the doc fix: 480 suites, 16,138 assertions, 1 red - the docs sweep reading a doc code span that split on `|`. Fixed on this branch; that suite re-run is green (7/7). Docs: `docs/CLI.md`, new subsection under "A command with words it cannot use refuses them". Evidence and the open edges (glued `|` with no spaces, `?` after a pipe, `section`) in `research/show-output-filter.md`.
cli(show): a pipe starts an output modifier, and the port name ends there
All checks were successful
CI / Typecheck (pull_request) Successful in 30s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Server smoke and Docker build (pull_request) Successful in 52s
CI / Test (Node 22) (pull_request) Successful in 1m0s
CI / Test (Node 24) (pull_request) Successful in 1m5s
CI / Arm auto-merge (pull_request) Successful in 4s
1753480de1
show interfaces Port 1 | include packets answered '% No interface Port 1 | include packets', naming a socket nobody asked about and never mentioning the one part of the line the console had not understood. IOS's grammar is 'command | {begin | include | exclude} regular-expression', so the pipe ends the command and the object named before it is complete. Parsed once, before any view opens: every door answers the same four ways, and the filter word is compared as a keyword. No filter is modelled - an unfiltered block printed under a filter would be trusted lines the box had already dropped.
forgejo-actions scheduled this pull request to auto merge when all checks succeed 2026-11-24 06:36:21 +00:00
jaylouisw deleted branch rev/1124-0612 2026-11-24 06:38:12 +00:00
Sign in to join this conversation.
No description provided.