[PATCH] libmisc/shell: Support terminal size as env variables

Chris Johns chrisj at rtems.org
Tue Nov 22 19:52:43 UTC 2022


On 23/11/22 12:44 am, Joel Sherrill wrote:
> On Tue, Nov 22, 2022, 6:02 AM <chrisj at rtems.org <mailto:chrisj at rtems.org>> wrote:
>     From: Chris Johns <chrisj at rtems.org <mailto:chrisj at rtems.org>>
> 
>     Closes #4763
>     ---
>      cpukit/libmisc/shell/main_edit.c | 17 +++++-
>      cpukit/libmisc/shell/main_help.c | 94 ++++++++++++++++++++------------
>      cpukit/libmisc/shell/shell.c     | 83 +++++++++++++++++++++++++++-
>      3 files changed, 154 insertions(+), 40 deletions(-)
> 
>     diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
>     index 4cc742719a..16c44f2a11 100644
>     --- a/cpukit/libmisc/shell/main_edit.c
>     +++ b/cpukit/libmisc/shell/main_edit.c
>     @@ -755,8 +755,21 @@ static void get_console_size(struct env *env) {
>        env->cols = ws.ws_col;
>        env->lines = ws.ws_row - 1;
>      #elif defined(__rtems__)
>     -  env->cols = 80;
>     -  env->lines = 25;
>     +  char* e;
>     +  e = getenv("LINES");
>     +  if (e != NULL) {
>     +    int lines = strtol(e, 0, 10);
>     +    if (lines > 0) {
>     +      env->lines = lines - 1;
>     +    }
>     +  }
>     +  e = getenv("COLUMNS");
>     +  if (e != NULL) {
>     +    int cols = strtol(e, 0, 10);
>     +    if (cols > 0) {
>     +      env->cols = cols - 1;
>     +    }
>     +  }
> 
> Does this lose the default values if the environment variables are not set?
> 

Yes. I will add the defaults back and then push.

Thanks for the review.

Chris


More information about the devel mailing list