Documentation: review applications/nsh

This commit is contained in:
raiden00pl
2023-10-30 09:31:00 +01:00
committed by Xiang Xiao
parent 8ad88a3fc5
commit 041308f950
8 changed files with 129 additions and 110 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
*************************** ===========================
NSH "Built-In" Applications NSH "Built-In" Applications
*************************** ===========================
**Overview.** In addition to these commands that are a part of NSH, **Overview.** In addition to these commands that are a part of NSH,
external programs can also be executed as NSH commands. These external external programs can also be executed as NSH commands. These external
@@ -27,7 +27,7 @@ Note that no detailed help information beyond the name of the built-in
application is provided. application is provided.
Built-In Applications Built-In Applications
~~~~~~~~~~~~~~~~~~~~~ =====================
**Overview.** The underlying logic that supports the NSH built-in **Overview.** The underlying logic that supports the NSH built-in
applications is called "Built-In Applications". The builtin application applications is called "Built-In Applications". The builtin application
@@ -185,7 +185,7 @@ be mentioned.
functionality. functionality.
Synchronous Built-In Applications Synchronous Built-In Applications
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =================================
By default, built-in commands started from the NSH command line will run By default, built-in commands started from the NSH command line will run
asynchronously with NSH. If you want to force NSH to execute commands asynchronously with NSH. If you want to force NSH to execute commands
File diff suppressed because it is too large Load Diff
+13
View File
@@ -488,3 +488,16 @@ Configuration Description
``CONFIG_NSH_FATSECTSIZE`` This is the sector size use with the FAT FS. Default is 512. ``CONFIG_NSH_FATSECTSIZE`` This is the sector size use with the FAT FS. Default is 512.
============================== ======================================================= ============================== =======================================================
Common Problems
===============
Problem::
The function 'readline' is undefined.
Usual Cause:
* The following is missing from your `defconfig` file::
CONFIG_SYSTEM_READLINE=y
@@ -1,6 +1,6 @@
************************* ========================*
Customizing the NuttShell Customizing the NuttShell
************************* ========================*
**Overview.** The NuttShell (NSH) is a simple shell application that may **Overview.** The NuttShell (NSH) is a simple shell application that may
be used with NuttX. It supports a variety of commands and is (very) be used with NuttX. It supports a variety of commands and is (very)
@@ -10,7 +10,7 @@ customizing NSH: Adding new commands, changing the initialization
sequence, etc. sequence, etc.
The NSH Library and NSH Initialization The NSH Library and NSH Initialization
************************************** ======================================
**Overview.** NSH is implemented as a library that can be found at **Overview.** NSH is implemented as a library that can be found at
``apps/nshlib``. As a library, it can be custom built into any ``apps/nshlib``. As a library, it can be custom built into any
@@ -23,7 +23,7 @@ as their application ``main()`` function. That initialization performed
by that example is discussed in the following paragraphs. by that example is discussed in the following paragraphs.
NSH Initialization sequence NSH Initialization sequence
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------
The NSH start-up sequence is very simple. As an example, the code at The NSH start-up sequence is very simple. As an example, the code at
``apps/system/nsh/nsh_main.c`` illustrates how to start NSH. It simple ``apps/system/nsh/nsh_main.c`` illustrates how to start NSH. It simple
@@ -43,7 +43,7 @@ does the following:
finished the entire NSH initialization sequence. finished the entire NSH initialization sequence.
``nsh_initialize()`` ``nsh_initialize()``
~~~~~~~~~~~~~~~~~~~~ --------------------
The NSH initialization function, ``nsh_initialize()``, be found in The NSH initialization function, ``nsh_initialize()``, be found in
``apps/nshlib/nsh_init.c``. It does only four things: ``apps/nshlib/nsh_init.c``. It does only four things:
@@ -118,7 +118,7 @@ The NSH initialization function, ``nsh_initialize()``, be found in
found in ``apps/nshlib/nsh_romfsimg.h``. found in ``apps/nshlib/nsh_romfsimg.h``.
NSH Commands NSH Commands
************ ============
**Overview.** NSH supports a variety of commands as part of the NSH **Overview.** NSH supports a variety of commands as part of the NSH
program. All of the NSH commands are listed in the NSH documentation program. All of the NSH commands are listed in the NSH documentation
@@ -133,7 +133,7 @@ commands will be missing from the list of commands presented by
table `above <#cmddependencies>`__. table `above <#cmddependencies>`__.
Adding New NSH Commands Adding New NSH Commands
~~~~~~~~~~~~~~~~~~~~~~~ -----------------------
New commands can be added to the NSH very easily. You simply need to add New commands can be added to the NSH very easily. You simply need to add
two things: two things:
+7 -2
View File
@@ -2,9 +2,14 @@
NuttShell (NSH) NuttShell (NSH)
=============== ===============
The NuttShell is a very complete shell system to be used in NuttX, similar to bash and other similar options. It supports a rich set of included commands, scripting and the ability to run your own applications as "builtin" (part of the same NuttX binary). NSH is implemented as an application where most of the functionality is part of the library called `nshlib`. The NuttShell is a very complete shell system to be used in NuttX, similar to
bash and other similar options. It supports a rich set of included commands,
scripting and the ability to run your own applications as "builtin" (part of the
same NuttX binary). NSH is implemented as an application where most of the
functionality is part of the library called `nshlib`.
As such, NSH is completely optional and can be disabled so that NuttX directly starts a given task instead of the main ``nsh`` application. As such, NSH is completely optional and can be disabled so that NuttX directly
starts a given task instead of the main ``nsh`` application.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
@@ -1,6 +1,6 @@
****************************** ==============================
Customizing NSH Initialization Customizing NSH Initialization
****************************** ==============================
**Ways to Customize NSH Initialization**. There are three ways to **Ways to Customize NSH Initialization**. There are three ways to
customize the NSH start-up behavior. Here they are presented in order of customize the NSH start-up behavior. Here they are presented in order of
@@ -28,7 +28,7 @@ increasing difficulty:
deserves its own paragraph deserves its own paragraph
NuttShell Start up Scripts NuttShell Start up Scripts
~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------------------
First of all you should look at `NSH Start-Up Script <#startupscript>`__ First of all you should look at `NSH Start-Up Script <#startupscript>`__
paragraph. Most everything you need to know can be found there. That paragraph. Most everything you need to know can be found there. That
+6 -6
View File
@@ -1,9 +1,9 @@
*********** ===========
Shell Login Shell Login
*********** ===========
Enabling Shell Logins Enabling Shell Logins
********************* =====================
NuttShell sessions can be protected by requiring that the user supply NuttShell sessions can be protected by requiring that the user supply
username and password credentials at the beginning of the session. username and password credentials at the beginning of the session.
@@ -39,7 +39,7 @@ will be closed. That number is controlled by::
CONFIG_NSH_LOGIN_FAILCOUNT=3 CONFIG_NSH_LOGIN_FAILCOUNT=3
Verification of Credentials Verification of Credentials
*************************** ===========================
There are three ways that NSH can be configured to verify user There are three ways that NSH can be configured to verify user
credentials at login time: credentials at login time:
@@ -89,7 +89,7 @@ credentials at login time:
CONFIG_NSH_LOGIN_PASSWD=y CONFIG_NSH_LOGIN_PASSWD=y
Password Files Password Files
************** ==============
NuttX can also be configured to support a password file, by default at NuttX can also be configured to support a password file, by default at
``/etc/passwd``. This option enables support for a password file:: ``/etc/passwd``. This option enables support for a password file::
@@ -150,7 +150,7 @@ Instead, the password file will be consulted to verify the user
credentials. credentials.
Creating a Password File for a ROMFS File System Creating a Password File for a ROMFS File System
************************************************ ================================================
What we want to accomplish is a ROMFS file system, mounted at ``/etc`` What we want to accomplish is a ROMFS file system, mounted at ``/etc``
and containing the password file, ``passwd`` like:: and containing the password file, ``passwd`` like::
+11 -10
View File
@@ -1,9 +1,9 @@
.. include:: /substitutions.rst .. include:: /substitutions.rst
.. _nsh: .. _nsh:
******** ========
Overview Overview
******** ========
**The NSH Library**. The ``apps/nshlib`` sub-directory contains the **The NSH Library**. The ``apps/nshlib`` sub-directory contains the
NuttShell (NSH) library. This library can easily to linked to NuttShell (NSH) library. This library can easily to linked to
@@ -12,7 +12,7 @@ produce a NSH application (See as an example
application for NuttX. application for NuttX.
Console/NSH Front End Console/NSH Front End
********************* =====================
**NSH Consoles**. Using settings in the configuration file, NSH may be **NSH Consoles**. Using settings in the configuration file, NSH may be
configured to use (1) the serial stdin/out, (2) a USB serial configured to use (1) the serial stdin/out, (2) a USB serial
@@ -83,7 +83,7 @@ Key Binding Editor Action
===================== ================================================ ===================== ================================================
Command Overview Command Overview
**************** ================
**Simple, Re-directed, and Background Commands**. The NuttShell **Simple, Re-directed, and Background Commands**. The NuttShell
(NSH) is a simple shell application. NSH supports the following (NSH) is a simple shell application. NSH supports the following
@@ -159,7 +159,7 @@ significant resources, they are disabled by default.
also selected. also selected.
Conditional Command Execution Conditional Command Execution
***************************** =============================
An ``if-then[-else]-fi`` construct is also supported in order to An ``if-then[-else]-fi`` construct is also supported in order to
support conditional execution of commands. This works from the support conditional execution of commands. This works from the
@@ -191,7 +191,7 @@ Examples:
1 is not equal 0 1 is not equal 0
Looping Looping
******* =======
**Looping Constructs**. ``while-do-done`` and ``until-do-done`` **Looping Constructs**. ``while-do-done`` and ``until-do-done``
looping constructs are also supported. These work from the command looping constructs are also supported. These work from the command
@@ -233,7 +233,7 @@ the loop will immediately terminate and execution will continue
with the next command immediately following the ``done`` token. with the next command immediately following the ``done`` token.
Built-In Variables Built-In Variables
****************** ==================
====== ==================================================== ====== ====================================================
``$?`` The result of the last simple command execution. |br| ``$?`` The result of the last simple command execution. |br|
@@ -242,7 +242,7 @@ Built-In Variables
====== ==================================================== ====== ====================================================
Current Working Directory Current Working Directory
************************* =========================
``cd`` **and** ``pwd``. All path arguments to commands may be ``cd`` **and** ``pwd``. All path arguments to commands may be
either an absolute path or a path relative to the current working either an absolute path or a path relative to the current working
@@ -251,7 +251,7 @@ directory. The current working directory is set using the
``pwd`` command or by using the ``echo $PWD`` command. ``pwd`` command or by using the ``echo $PWD`` command.
Environment Variables Environment Variables
********************* =====================
========== ================================================ ========== ================================================
``PATH`` The default path in the file systems to look |br| ``PATH`` The default path in the file systems to look |br|
@@ -260,8 +260,9 @@ Environment Variables
``OLDPWD`` The previous working directory ``OLDPWD`` The previous working directory
========== ================================================ ========== ================================================
NSH Start-Up Script NSH Start-Up Script
******************* ===================
**NSH Start-Up Script**. NSH supports options to provide a start **NSH Start-Up Script**. NSH supports options to provide a start
up script for NSH. In general this capability is enabled with up script for NSH. In general this capability is enabled with