Changeset 259328a7 in rtems


Ignore:
Timestamp:
Dec 16, 2013, 12:59:51 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11, master
Children:
99c2323
Parents:
24d09194
Message:

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.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/shell/main_help.c

    r24d09194 r259328a7  
    1313
    1414#include <stdio.h>
     15#include <stdlib.h>
    1516#include <time.h>
    1617
     
    8081)
    8182{
    82   int col,line,arg;
     83  int col,line,lines,arg;
     84  char* lines_env;
    8385  rtems_shell_topic_t *topic;
    8486  rtems_shell_cmd_t * shell_cmd = rtems_shell_first_cmd;
     87
     88  lines_env = getenv("SHELL_LINES");
     89  if (lines_env)
     90    lines = strtol(lines_env, 0, 0);
     91  else
     92    lines = 16;
    8593
    8694  if (argc<2) {
     
    107115  line = 0;
    108116  for (arg = 1;arg<argc;arg++) {
    109     if (line>16) {
     117    if (lines && (line > lines)) {
    110118      printf("Press any key to continue...");getchar();
    111119      printf("\n");
     
    128136      if (!strcmp(topic->topic,shell_cmd->topic))
    129137        line+= rtems_shell_help_cmd(shell_cmd);
    130       if (line>16) {
     138      if (lines && (line > lines)) {
    131139        printf("Press any key to continue...");
    132140        getchar();
  • doc/shell/general.t

    r24d09194 r259328a7  
    1212@itemize @bullet
    1313
     14@item @code{help} - Print command help
    1415@item @code{alias} - Add alias for an existing command
    1516@item @code{date} - Print or set current date and time
     
    3940@c
    4041@page
     42@subsection help - Print command help
     43
     44@pgindex help
     45
     46@subheading SYNOPSYS:
     47
     48@example
     49help misc
     50@end example
     51
     52@subheading DESCRIPTION:
     53
     54This command prints the command help. Help without arguments prints a
     55list of topics and help with a topic prints the help for that topic.
     56
     57@subheading EXIT STATUS:
     58
     59This command returns 0.
     60
     61@subheading NOTES:
     62
     63The help print will break the output up based on the environment
     64variable SHELL_LINES. If this environment variable is not set the
     65default is 16 lines. If set the number of lines is set to that the
     66value. If the shell lines is set 0 there will be no break.
     67
     68@subheading EXAMPLES:
     69
     70The following is an example of how to use @code{alias}:
     71
     72@example
     73SHLL [/] $ help
     74help: ('r' repeat last cmd - 'e' edit last cmd)
     75  TOPIC? The topics are
     76   mem, misc, files, help, rtems, network, monitor
     77SHLL [/] $ help misc
     78help: list for the topic 'misc'
     79alias        - alias old new
     80time         - time command [arguments...]
     81joel         - joel [args] SCRIPT
     82date         - date [YYYY-MM-DD HH:MM:SS]
     83echo         - echo [args]
     84sleep        - sleep seconds [nanoseconds]
     85id           - show uid, gid, euid, and egid
     86tty          - show ttyname
     87whoami       - show current user
     88logoff       - logoff from the system
     89setenv       - setenv [var] [string]
     90getenv       - getenv [var]
     91unsetenv     - unsetenv [var]
     92umask        - umask [new_umask]
     93Press any key to continue...
     94rtc          - real time clock read and set
     95SHLL [/] $ setenv SHELL_ENV 0
     96SHLL [/] $ help misc
     97help: list for the topic 'misc'
     98alias        - alias old new
     99time         - time command [arguments...]
     100joel         - joel [args] SCRIPT
     101date         - date [YYYY-MM-DD HH:MM:SS]
     102echo         - echo [args]
     103sleep        - sleep seconds [nanoseconds]
     104id           - show uid, gid, euid, and egid
     105tty          - show ttyname
     106whoami       - show current user
     107logoff       - logoff from the system
     108setenv       - setenv [var] [string]
     109getenv       - getenv [var]
     110unsetenv     - unsetenv [var]
     111umask        - umask [new_umask]
     112rtc          - real time clock read and set
     113@end example
     114
     115@subheading CONFIGURATION:
     116
     117This command has no configuration.
     118
     119@c
     120@c
     121@c
     122@page
    41123@subsection alias - add alias for an existing command
    42124
     
    81163@findex CONFIGURE_SHELL_COMMAND_ALIAS
    82164
    83 This command is included in the default shell command set. 
     165This command is included in the default shell command set.
    84166When building a custom command set, define
    85167@code{CONFIGURE_SHELL_COMMAND_ALIAS} to have this
     
    131213arguments, it prints the current date and time.  When invoked
    132214with both @code{date} and @code{time} arguments, it sets the
    133 current time. 
     215current time.
    134216
    135217The @code{date} is specified in @code{YYYY-MM-DD} format.
     
    161243@findex CONFIGURE_SHELL_COMMAND_DATE
    162244
    163 This command is included in the default shell command set. 
     245This command is included in the default shell command set.
    164246When building a custom command set, define
    165247@code{CONFIGURE_SHELL_COMMAND_DATE} to have this
     
    209291echo prints its arguments on the standard output, separated by spaces.
    210292Unless the @b{-n} option is present, a newline is output following the
    211 arguments.  The @b{-e} option causes echo to treat the escape sequences 
     293arguments.  The @b{-e} option causes echo to treat the escape sequences
    212294specially, as described in the following paragraph.  The @b{-e} option is the
    213295default, and is provided solely for compatibility with other systems.
     
    243325
    244326@item \0digits
    245 Output the character whose value is given by zero to three digits. 
     327Output the character whose value is given by zero to three digits.
    246328If there are zero digits, a nul character is output.
    247329
     
    280362@findex CONFIGURE_SHELL_COMMAND_ECHO
    281363
    282 This command is included in the default shell command set. 
     364This command is included in the default shell command set.
    283365When building a custom command set, define
    284366@code{CONFIGURE_SHELL_COMMAND_ECHO} to have this
     
    360442pause after executing the first command before the prompt
    361443is printed.  The second command completes very quickly
    362 from a human perspective and there is no noticeable 
     444from a human perspective and there is no noticeable
    363445delay in the prompt being printed.
    364446@subheading CONFIGURATION:
     
    367449@findex CONFIGURE_SHELL_COMMAND_SLEEP
    368450
    369 This command is included in the default shell command set. 
     451This command is included in the default shell command set.
    370452When building a custom command set, define
    371453@code{CONFIGURE_SHELL_COMMAND_SLEEP} to have this
     
    450532@findex CONFIGURE_SHELL_COMMAND_ID
    451533
    452 This command is included in the default shell command set. 
     534This command is included in the default shell command set.
    453535When building a custom command set, define
    454536@code{CONFIGURE_SHELL_COMMAND_ID} to have this
     
    521603@findex CONFIGURE_SHELL_COMMAND_TTY
    522604
    523 This command is included in the default shell command set. 
     605This command is included in the default shell command set.
    524606When building a custom command set, define
    525607@code{CONFIGURE_SHELL_COMMAND_TTY} to have this
     
    592674@findex CONFIGURE_SHELL_COMMAND_WHOAMI
    593675
    594 This command is included in the default shell command set. 
     676This command is included in the default shell command set.
    595677When building a custom command set, define
    596678@code{CONFIGURE_SHELL_COMMAND_WHOAMI} to have this
     
    664746@findex CONFIGURE_SHELL_COMMAND_GETENV
    665747
    666 This command is included in the default shell command set. 
     748This command is included in the default shell command set.
    667749When building a custom command set, define
    668750@code{CONFIGURE_SHELL_COMMAND_GETENV} to have this
     
    737819@findex CONFIGURE_SHELL_COMMAND_SETENV
    738820
    739 This command is included in the default shell command set. 
     821This command is included in the default shell command set.
    740822When building a custom command set, define
    741823@code{CONFIGURE_SHELL_COMMAND_SETENV} to have this
     
    808890@findex CONFIGURE_SHELL_COMMAND_UNSETENV
    809891
    810 This command is included in the default shell command set. 
     892This command is included in the default shell command set.
    811893When building a custom command set, define
    812894@code{CONFIGURE_SHELL_COMMAND_UNSETENV} to have this
     
    9511033@findex CONFIGURE_SHELL_COMMAND_LOGOFF
    9521034
    953 This command is included in the default shell command set. 
     1035This command is included in the default shell command set.
    9541036When building a custom command set, define
    9551037@code{CONFIGURE_SHELL_COMMAND_LOGOFF} to have this
     
    10001082@findex CONFIGURE_SHELL_COMMAND_RTC
    10011083
    1002 This command is included in the default shell command set. 
     1084This command is included in the default shell command set.
    10031085When building a custom command set, define
    10041086@code{CONFIGURE_SHELL_COMMAND_RTC} to have this
Note: See TracChangeset for help on using the changeset viewer.