Conversation
Route every cmd_buff-to-terminal write through shell_write_cmd() and every prompt print through shell_print_prompt(), replacing six copies of the default_prompt lookup. shell_process_char() becomes internal API so the host tests can drive line editing without the shell thread. No behavior change. Prep for obscured input and runtime prompt changes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Hand-built struct shell with a write-capturing transport and no thread, plus a two-command root tree. Covers insert echo, backspace, subcommand dispatch and unknown-command handling. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Zephyr-compatible primitives for application login flows (#59): - shell_obscure_set(): echo '*' for every cmd_buff write; returns the previous state. CONFIG_ZSHELL_START_OBSCURED sets the initial state. - shell_set_root_cmd(): one selection shared by all instances, as upstream. Dispatch and tab completion place the root at argv[0] so typed input can only walk beneath it; help is itself a root command and therefore unreachable while a root is selected. NULL restores the tree, an unknown name returns -EINVAL. CONFIG_ZSHELL_CMD_ROOT (string) applies at init and warns if it names no command. - shell_prompt_change(): bounded by CONFIG_ZSHELL_PROMPT_BUFF_SIZE under CONFIG_ZSHELL_PROMPT_CHANGE (default y, 20); -EINVAL on NULL/oversize, -EPERM when disabled, as upstream. - shell_history_purge(): takes the shell because history is embedded here rather than pointed to; no-op without CONFIG_ZSHELL_HISTORY. shell_root_cmd_find() replaces the three private root lookups. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…urge Ten cases from #59: obscure toggle return value, obscured insert/delete and mid-line rewrite, default-off state, valid/invalid root selection, dispatch beneath the root, rejection of sibling roots and help, clearing the root, root-aware completion, prompt bounds, and purge. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`login <password>` purges history, clears obscuring, restores the full tree and prompt; `logout` reverses it. `idf.py -DLOGIN=y build` appends sdkconfig.login (START_OBSCURED=y, CMD_ROOT="login") so the demo boots locked. The command-line SDKCONFIG_DEFAULTS override cannot be used here because the project CMake sets the list itself. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Tab completion echoed completed text in clear while obscured; route the two insert writes through shell_write_cmd() and test it. - shell_prompt_change() copies under wr_mtx so it cannot interleave with an in-progress write; @note the -EBUSY divergence from upstream. - Apply CONFIG_ZSHELL_CMD_ROOT once: the selection is shared, so a second shell_init() after a login must not relock the first instance. - shell_make_argv_root() replaces the duplicated root-at-argv[0] shape in dispatch and completion; cmd_help uses shell_root_cmd_find(). - Doxygen: @PARAM on the new APIs, accurate help/completion wording, history purge threading note; root lookup helpers move to internal API. - Drop the dead CONFIG_ZSHELL_PROMPT_BUFF_SIZE fallback define. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ading - Register the builtins in the test harness so `help` exists; assert it lands on the root handler while a root is selected and lists the tree once cleared (previously passed vacuously because help was unregistered). - @note on shell_obscure_set(): plain bool, not upstream's atomic flag. - Extend the shell_prompt_change() note: the prompt is read outside the lock when printed, so call from the shell thread. - Drop the redundant `default n` on ZSHELL_START_OBSCURED. - .gitignore build*/ so variant build dirs stay untracked. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #59.
Adds the four primitives Zephyr's login sample composes, with the same signatures and return codes as upstream
include/zephyr/shell/shell.h:shell_obscure_set()-- echo*, returns previous stateCONFIG_ZSHELL_START_OBSCUREDshell_set_root_cmd()-- typed input dispatches beneath one root; help and completion see only its subtree;NULLrestores the treeCONFIG_ZSHELL_CMD_ROOTshell_prompt_change()-- runtime promptCONFIG_ZSHELL_PROMPT_CHANGE(default y),CONFIG_ZSHELL_PROMPT_BUFF_SIZE(2..40, default 20)shell_history_purge()-- drop the entry holding a passwordThe shell supplies mechanics only; the application owns the credential check.
examples/shell_demogainslogin/logoutmodeled onsamples/subsys/shell/shell_module/src/login_cmd.c;idf.py -DLOGIN=y buildstarts it locked.Divergences (all documented on the declaration)
shell_prompt_change()blocks on the output mutex instead of trylocking, so-EBUSYis never returned.shell_obscure_set()writes a plainbool; upstream sets an atomic flag. Call from the shell thread.shell_history_purge(sh)takes the shell, since Boreas embeds the history rather than pointing at it. Replaces upstream'sz_shell_history_purge(sh->history).CONFIG_ZSHELL_CMD_ROOTis applied once, by the firstshell_init(), since the selection is shared by every instance. A latershell_init()must not re-lock a shell that has already logged in.Notes
cmd_buffon the terminal now goes throughshell_write_cmd(), so obscuring covers insert, delete, cursor moves, history recall, and completed text -- not just the echo of the typed key.argvarrays grow by one slot: a selected root occupiesargv[0]ahead of the typed tokens.struct shell_ctxgrows by the prompt buffer whenPROMPT_CHANGEis on..gitignorenow coversbuild*/so per-variant build dirs (build_login/,build_linux/) stay untracked.Test
shell_process_char()with no shell thread, checking both terminal bytes and dispatch.shell_obscure_set()previous-state contract, valid/invalid root selection, dispatch beneath the root, sibling roots andhelpunreachable while a root is selected (with a positive control once cleared), completion scoped to the root, prompt change bounds, history purge.idf.py --preview set-target linux), including the 17 new shell tests.-Werror; earlier on-target run of this suite passed before the final review-fix commit.CONFIG_ZSHELL_START_OBSCURED=ystartup and thePROMPT_CHANGE=n/HISTORY=nfallbacks, which need a second test config.🤖 Generated with Claude Code