Re: [PATCH] add clear command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023/09/21 11:00, Huang Shijie wrote:
> Add the clear command for crash.
> Use it to clear the screen.

Sorry, but I would not like to add a command just to do this.

Currently, we can run the clear command like this:

   crash> !clear

If this is not acceptable to you, crash has some external commands that 
can be run without the exclamation mark(!), so I would suggest adding 
the command to them:

static int
is_external_command(void)
{
         int i;
         char *cmd;
         char command[BUFSIZE];

         cmd = args[0];

         if (STREQ(cmd, "vi") ||
             STREQ(cmd, "pwd") ||
             STREQ(cmd, "grep") ||
             STREQ(cmd, "cat") ||
             STREQ(cmd, "more") ||
             STREQ(cmd, "less") ||
             STREQ(cmd, "echo") ||
-           STREQ(cmd, "ls")) {
+           STREQ(cmd, "ls") ||
+           STREQ(cmd, "clear")) {
                  sprintf(command, "%s", cmd);

Thanks,
Kazu

> 
> Signed-off-by: Huang Shijie <shijie@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> This is just for tool "crash".
> ---
>   defs.h        | 2 ++
>   global_data.c | 1 +
>   help.c        | 8 ++++++++
>   tools.c       | 9 +++++++++
>   4 files changed, 20 insertions(+)
> 
> diff --git a/defs.h b/defs.h
> index 96a7a2a..a72aa69 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -5283,6 +5283,7 @@ void cmd_test(void);         /* test.c */
>   void cmd_ascii(void);        /* tools.c */
>   void cmd_sbitmapq(void);     /* sbitmap.c */
>   void cmd_bpf(void);          /* bfp.c */
> +void cmd_clear(void);        /* tools.c */
>   void cmd_set(void);          /* tools.c */
>   void cmd_eval(void);         /* tools.c */
>   void cmd_list(void);         /* tools.c */
> @@ -5883,6 +5884,7 @@ extern char *help_ascii[];
>   extern char *help_bpf[];
>   extern char *help_bt[];
>   extern char *help_btop[];
> +extern char *help_clear[];
>   extern char *help_dev[];
>   extern char *help_dis[];
>   extern char *help_eval[];
> diff --git a/global_data.c b/global_data.c
> index f9bb7d0..2157e8c 100644
> --- a/global_data.c
> +++ b/global_data.c
> @@ -75,6 +75,7 @@ struct command_table_entry linux_command_table[] = {
>           {"bpf",     cmd_bpf,     help_bpf,     0},
>           {"bt",      cmd_bt,      help_bt,      REFRESH_TASK_TABLE},
>   	{"btop",    cmd_btop,    help_btop,    0},
> +	{"clear",   cmd_clear,   help_clear,   0},
>   	{"dev",     cmd_dev,     help_dev,     0},
>   	{"dis",     cmd_dis,     help_dis,     MINIMAL},
>   	{"eval",    cmd_eval,    help_eval,    MINIMAL},
> diff --git a/help.c b/help.c
> index cc7ab20..04284e5 100644
> --- a/help.c
> +++ b/help.c
> @@ -2293,6 +2293,14 @@ char *help_btop[] = {
>   NULL
>   };
>   
> +char *help_clear[] = {
> +"clear",
> +"Clear the screen",
> +" ",
> +"Used to clear the screen",
> +NULL
> +};
> +
>   char *help_extend[] = {
>   "extend",
>   "extend the %s command set",
> diff --git a/tools.c b/tools.c
> index 0f2db10..96c8dbe 100644
> --- a/tools.c
> +++ b/tools.c
> @@ -1783,6 +1783,15 @@ mkstring(char *s, int size, ulong flags, const char *opt)
>   	return(s);
>   }
>   
> +/*
> + * Clear the screen.
> + */
> +void
> +cmd_clear(void)
> +{
> +	system("clear");
> +}
> +
>   /*
>    *  Prints the requested number of BACKSPACE characters.
>    */
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux