cli: a config command word shortens to what is still unique (host r1, vla 20, sp, do sh) #1740

Merged
jaylouisw merged 1 commit from rev/1116-2200 into main 2026-11-16 22:19:45 +00:00
Owner

Question

Does a shortened config-mode command word resolve the way a shortened EXEC one does, and against what table?

Sources

Verdict

Known, and it was wrong here. A box accepts any unique prefix of the first word of a config line; this console accepted exactly one (int, hard-coded) and refused host r1, vla 20, sp priority 4096, do sh ver.

Changed

  • engine/cli.js: CONFIG_WORDS (21 entries, every word a head === the config dispatcher compares against) + resolveCommandWord at the head of _configMode(); the word after do resolves against EXEC_WORDS.
  • % Ambiguous config command "i": interface | ip | ipv6 (type more characters) - and the mode is left alone.
  • test/command-word-abbreviation.test.js: +54 assertions (74 -> 128) - shortened lines answer byte-for-byte as the whole spelling, ambiguity leaves mode === "config", enabl keeps its old refusal, and the second word of a config line is still not resolved (ip ro ..., no vla 20) so the boundary stays a decision.
  • docs/CLI.md and research/command-word-abbreviation.md updated.

Tests

  • node scripts/syntax-check.js: 364 files, all OK
  • npm test: 293 suites, 10452 assertions, 0 failed

Unresolved

  • (config-if)# has no table yet (ip add, sw mo acc, desc, do sh run still refused) - next pass, same shape.
  • show is accepted at (config)# here where a box refuses it (pre-existing; sh ver now rides on that).
  • en at (config)# is end here; a box also has enable password, so it would call it ambiguous.
## Question Does a shortened **config-mode** command word resolve the way a shortened EXEC one does, and against what table? ## Sources - Connected Dots, *Invalid input detected at ^ marker* - a real box printing `Router(config)#int gi0/1` accepted and `do sh run` running the view, while `sh run` at `(config)#` is refused: https://www.connecteddots.online/resources/cisco/invalid-input-detected-at-marker - Cisco community HSRP thread - `D11(config)#do sh run int g0/1`, `SW1(config)#do sh run int gi0/1` from four boxes: https://community.cisco.com/t5/routing/hsrp-standby-router-is-unknow/td-p/4602792 - Cisco IOS XE 16 Fundamentals, *Using the Cisco IOS Command-Line Interface* - the abbreviation rule, stated for "commands and keywords" (no mode limit): https://cisco.com/c/en/us/td/docs/ios-xml/ios/fundamentals/configuration/xe-16/fundamentals-xe-16-book/cf-cli-basics.html ## Verdict Known, and it was wrong here. A box accepts any unique prefix of the first word of a config line; this console accepted exactly one (`int`, hard-coded) and refused `host r1`, `vla 20`, `sp priority 4096`, `do sh ver`. ## Changed - `engine/cli.js`: `CONFIG_WORDS` (21 entries, every `word` a `head ===` the config dispatcher compares against) + `resolveCommandWord` at the head of `_configMode()`; the word after `do` resolves against `EXEC_WORDS`. - `% Ambiguous config command "i": interface | ip | ipv6 (type more characters)` - and the mode is left alone. - `test/command-word-abbreviation.test.js`: +54 assertions (74 -> 128) - shortened lines answer byte-for-byte as the whole spelling, ambiguity leaves `mode === "config"`, `enabl` keeps its old refusal, and the second word of a config line is still not resolved (`ip ro ...`, `no vla 20`) so the boundary stays a decision. - `docs/CLI.md` and `research/command-word-abbreviation.md` updated. ## Tests - `node scripts/syntax-check.js`: 364 files, all OK - `npm test`: **293 suites, 10452 assertions, 0 failed** ## Unresolved - `(config-if)#` has no table yet (`ip add`, `sw mo acc`, `desc`, `do sh run` still refused) - next pass, same shape. - `show` is accepted at `(config)#` here where a box refuses it (pre-existing; `sh ver` now rides on that). - `en` at `(config)#` is `end` here; a box also has `enable password`, so it would call it ambiguous.
cli: a config command word shortens to what is still unique (host r1, vla 20, sp, do sh)
All checks were successful
CI / Classify the change (pull_request) Successful in 16s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 21s
CI / Server smoke test (pull_request) Successful in 24s
CI / Test (Node 20) (pull_request) Successful in 55s
CI / Test (Node 18) (pull_request) Successful in 58s
CI / Docker build (pull_request) Successful in 31s
CI / Test (Node 22) (pull_request) Successful in 1m0s
CI / Arm auto-merge (pull_request) Successful in 17s
4663e3d203
A real box accepts a shortened first word at (config)# - connecteddots.online
prints Router(config)#int gi0/1 opening the port and do sh run running the
view - while this console hard-coded exactly one (int) and refused host r1,
vla 20, sp priority 4096 and do sh ver. The first word of a config line now
resolves by prefix against CONFIG_WORDS, a table built from the config
dispatcher's own head === comparisons, and the word after do resolves against
EXEC_WORDS. A shared prefix is refused as '% Ambiguous config command' and
changes no state. The second word of a config line is still not resolved
(ip ro ..., no vla 20) - asserted, so it stays a decision.

test/command-word-abbreviation.test.js: +54 assertions (74 -> 128).
docs/CLI.md and research/command-word-abbreviation.md updated.
npm test: 293 suites, 10452 assertions, 0 failed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1740
No description provided.