Junbo-Zheng opened a new pull request, #4010:
URL: https://github.com/apache/nuttx-apps/pull/4010

   
   ## Summary
   
   Tab completion currently only matches command names: the whole line
   buffer is compared against the builtin table and NSH's command map, so
   `ls <TAB>` or `cd /da<TAB>` do nothing. This adds filesystem
   completion for the argument position in `readline_common.c`:
   
   - When the line contains a space (or the word starts with `/`), the
     last word is completed against directory entries instead of command
     names; the command position keeps the existing behavior unchanged.
   - The word is split at its last `/` into a directory part and a
     prefix (`cd /data/lo` -> entries of `/data/` matching `lo`; no `/`
     means the current working directory).
   - A single match appends the rest of the name plus `/` for a
     directory (so a following TAB descends into it) or a space
     otherwise.
   - Multiple matches are listed and the word is extended by their
     common prefix; with an empty prefix the candidates are only listed,
     so repeated TABs never append the same name over and over.
   - Hidden entries are skipped unless a prefix is typed, keeping `.` and
     `..` out of a bare TAB.
   
   ## Impact
   
   - **Users**: interactive shells gain filename completion for command
     arguments; command-name completion is unchanged.
   - **Build**: None -- no new Kconfig options, no new dependencies; the
     generation needs only `opendir`/`readdir` and two stack arrays of
     `NAME_MAX + 1`.
   - **Hardware**: None -- arch-independent, verified on sim.
   - **Documentation**: None.
   - **Security & Compatibility**: None.
   
   ## Testing
   
   `sim:nsh` (CMake build on Ubuntu 22.04):
   
   ```bash
   nsh> cd /d<TAB>
     data
     dev
   nsh> ls /dev/cons<TAB>
   nsh> ls /dev/console
    /dev/console
   nsh> cd /tmp/a<TAB>        (aa1/ aa2/ ab/ present)
     aa1
     aa2
     ab
   ```
   
   Command-name completion still works (`hel<TAB>` -> `hello`), and `ls
   <TAB>` in a single-entry directory lists the entry without inserting it.
   
   Signed-off-by: Junbo Zheng <[email protected]>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to