forked from Imagelibrary/rtems
cpukit/shell: Control help break with SHELL_LINES env variable.
Control the help command break with the SHELL_LINES evironment variable where the numeric value is the number of lines to break on. If the value is 0 the output is not broken. The default is 16 lines. Add shell documentation for the help command.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <rtems.h>
|
||||
@@ -79,10 +80,17 @@ static int rtems_shell_help(
|
||||
char * argv[]
|
||||
)
|
||||
{
|
||||
int col,line,arg;
|
||||
int col,line,lines,arg;
|
||||
char* lines_env;
|
||||
rtems_shell_topic_t *topic;
|
||||
rtems_shell_cmd_t * shell_cmd = rtems_shell_first_cmd;
|
||||
|
||||
lines_env = getenv("SHELL_LINES");
|
||||
if (lines_env)
|
||||
lines = strtol(lines_env, 0, 0);
|
||||
else
|
||||
lines = 16;
|
||||
|
||||
if (argc<2) {
|
||||
printf("help: ('r' repeat last cmd - 'e' edit last cmd)\n"
|
||||
" TOPIC? The topics are\n");
|
||||
@@ -106,7 +114,7 @@ static int rtems_shell_help(
|
||||
}
|
||||
line = 0;
|
||||
for (arg = 1;arg<argc;arg++) {
|
||||
if (line>16) {
|
||||
if (lines && (line > lines)) {
|
||||
printf("Press any key to continue...");getchar();
|
||||
printf("\n");
|
||||
line = 0;
|
||||
@@ -127,7 +135,7 @@ static int rtems_shell_help(
|
||||
while (shell_cmd) {
|
||||
if (!strcmp(topic->topic,shell_cmd->topic))
|
||||
line+= rtems_shell_help_cmd(shell_cmd);
|
||||
if (line>16) {
|
||||
if (lines && (line > lines)) {
|
||||
printf("Press any key to continue...");
|
||||
getchar();
|
||||
printf("\n");
|
||||
|
||||
@@ -11,6 +11,7 @@ The RTEMS shell has the following general commands:
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item @code{help} - Print command help
|
||||
@item @code{alias} - Add alias for an existing command
|
||||
@item @code{date} - Print or set current date and time
|
||||
@item @code{echo} - Produce message in a shell script
|
||||
@@ -34,6 +35,87 @@ This section details the General Commands available. A
|
||||
subsection is dedicated to each of the commands and
|
||||
describes the behavior and configuration of that
|
||||
command as well as providing an example usage.
|
||||
@c
|
||||
@c
|
||||
@c
|
||||
@page
|
||||
@subsection help - Print command help
|
||||
|
||||
@pgindex help
|
||||
|
||||
@subheading SYNOPSYS:
|
||||
|
||||
@example
|
||||
help misc
|
||||
@end example
|
||||
|
||||
@subheading DESCRIPTION:
|
||||
|
||||
This command prints the command help. Help without arguments prints a
|
||||
list of topics and help with a topic prints the help for that topic.
|
||||
|
||||
@subheading EXIT STATUS:
|
||||
|
||||
This command returns 0.
|
||||
|
||||
@subheading NOTES:
|
||||
|
||||
The help print will break the output up based on the environment
|
||||
variable SHELL_LINES. If this environment variable is not set the
|
||||
default is 16 lines. If set the number of lines is set to that the
|
||||
value. If the shell lines is set 0 there will be no break.
|
||||
|
||||
@subheading EXAMPLES:
|
||||
|
||||
The following is an example of how to use @code{alias}:
|
||||
|
||||
@example
|
||||
SHLL [/] $ help
|
||||
help: ('r' repeat last cmd - 'e' edit last cmd)
|
||||
TOPIC? The topics are
|
||||
mem, misc, files, help, rtems, network, monitor
|
||||
SHLL [/] $ help misc
|
||||
help: list for the topic 'misc'
|
||||
alias - alias old new
|
||||
time - time command [arguments...]
|
||||
joel - joel [args] SCRIPT
|
||||
date - date [YYYY-MM-DD HH:MM:SS]
|
||||
echo - echo [args]
|
||||
sleep - sleep seconds [nanoseconds]
|
||||
id - show uid, gid, euid, and egid
|
||||
tty - show ttyname
|
||||
whoami - show current user
|
||||
logoff - logoff from the system
|
||||
setenv - setenv [var] [string]
|
||||
getenv - getenv [var]
|
||||
unsetenv - unsetenv [var]
|
||||
umask - umask [new_umask]
|
||||
Press any key to continue...
|
||||
rtc - real time clock read and set
|
||||
SHLL [/] $ setenv SHELL_ENV 0
|
||||
SHLL [/] $ help misc
|
||||
help: list for the topic 'misc'
|
||||
alias - alias old new
|
||||
time - time command [arguments...]
|
||||
joel - joel [args] SCRIPT
|
||||
date - date [YYYY-MM-DD HH:MM:SS]
|
||||
echo - echo [args]
|
||||
sleep - sleep seconds [nanoseconds]
|
||||
id - show uid, gid, euid, and egid
|
||||
tty - show ttyname
|
||||
whoami - show current user
|
||||
logoff - logoff from the system
|
||||
setenv - setenv [var] [string]
|
||||
getenv - getenv [var]
|
||||
unsetenv - unsetenv [var]
|
||||
umask - umask [new_umask]
|
||||
rtc - real time clock read and set
|
||||
@end example
|
||||
|
||||
@subheading CONFIGURATION:
|
||||
|
||||
This command has no configuration.
|
||||
|
||||
@c
|
||||
@c
|
||||
@c
|
||||
|
||||
Reference in New Issue
Block a user