Re: [Crash-utility] [PATCH] add clear command

2023-10-11 Thread 萩尾 一仁
On 2023/10/10 20:16, Mathias Krause wrote:
> On 29.09.23 02:44, HAGIO KAZUHITO(萩尾 一仁) wrote:
>> 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
>>
>> [snip]
> 
> ...or, even simpler, by using Ctrl+L.

yes, I also suggested it.
https://listman.redhat.com/archives/crash-utility/2023-September/010981.html

> 
> Why hook up a new command when there's even a dedicated key combination
> for it?

I don't use the clear command so I'm not sure, but I remembered a person 
using the command on his terminal.  Many of Linux distributions still 
have it, there might be the same people like him.  Then it may be 
friendly also for crash to have it, not so hard.

Just my two cents.

Thanks,
Kazu
--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


Re: [Crash-utility] [PATCH] add clear command

2023-10-10 Thread Mathias Krause
On 29.09.23 02:44, HAGIO KAZUHITO(萩尾 一仁) wrote:
> 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
> 
> [snip]

...or, even simpler, by using Ctrl+L.

Why hook up a new command when there's even a dedicated key combination
for it?

Cheers,
Mathias

--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


Re: [Crash-utility] [PATCH] add clear command

2023-10-10 Thread 萩尾 一仁
On 2023/10/10 15:09, lijiang wrote:
> On Tue, Oct 10, 2023 at 8:31 AM HAGIO KAZUHITO(萩尾 一仁) 
> wrote:
> 
>> On 2023/10/07 16:48, lijiang wrote:
>>> On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁) <
>> k-hagio...@nec.com>
>>> wrote:
>>>
 On 2023/09/29 9:58, Shijie Huang wrote:
> Hi Kazu,
>
> 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
>> 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.
>
> My final purpose is to use 'alias' to map the command to 'c':
>
>   alias c clear
>

 Ah, got it.  External commands cannot be used as a command for alias, so
 I added it exceptionally.

 Lianbo, is this OK?


>>> Sorry for the late reply.
>>>
>>> This seems acceptable. But I just have one question, please see the
>> comment
>>> below.
>>>
>>>
From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00 2001
 From: Kazuhito Hagio 
 Date: Fri, 29 Sep 2023 11:58:04 +0900
 Subject: [PATCH] Make "clear" external command runnable without "!" and
 alias-able

 Make the "clear" external command runnable without an exclamation point
 ("!") for convenient.  Additionally, make it acceptable as a command
 string for alias exceptionally in external commands.

 Signed-off-by: Kazuhito Hagio 
 ---
 cmdline.c | 4 
 main.c| 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

 diff --git a/cmdline.c b/cmdline.c
 index b7f919ae2279..65da04cbf9a5 100644
 --- a/cmdline.c
 +++ b/cmdline.c
 @@ -1833,6 +1833,10 @@ allocate_alias(int origin)
   if (get_command_table_entry(args[2]))
   found = TRUE;

 +   /* Accept the "clear" external command exceptionally. */
 +   if (STREQ(args[2], "clear"))
 +   found = TRUE;

>>>
>>> I added the debugging info here:
>>>
>>> +error(INFO, "args1->%s, args2->%s\n",args[1], args[2]);
>>> +   /* Accept the "clear" external command exceptionally. */
>>> +if (STREQ(args[2], "clear"))
>>> +   found = TRUE;
>>>
>>> And I did not see any output information with the string "clear".
>>> The variable 'found' won't be set to 'TRUE' unless it is initialized in
>> the
>>> alias_init() such as the "lsmod", right?
>>
>> No.  sorry, maybe I don't get your question... but this hunk is for
>> something like:
>>
>>
> This answers my question. Thank you, Kazu.
> 
> 
>> crash> alias c clear
>> alias: args1->c, args2->clear
>> ORIGIN   ALIASCOMMAND
>> runtime  cclear
>> crash> c
>> (I can confirm that the screen is cleared.)
>>
>> I don't intend to have it as a builtin alias.
>>
>>
> Looks good to me. So, for the patch: Ack.

Thanks, applied.
https://github.com/crash-utility/crash/commit/5e758aaa0fd8199e21a2d4d04b486bc873bd788b

Kazu
--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


Re: [Crash-utility] [PATCH] add clear command

2023-10-10 Thread lijiang
On Tue, Oct 10, 2023 at 8:31 AM HAGIO KAZUHITO(萩尾 一仁) 
wrote:

> On 2023/10/07 16:48, lijiang wrote:
> > On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁) <
> k-hagio...@nec.com>
> > wrote:
> >
> >> On 2023/09/29 9:58, Shijie Huang wrote:
> >>> Hi Kazu,
> >>>
> >>> 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
>  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.
> >>>
> >>> My final purpose is to use 'alias' to map the command to 'c':
> >>>
> >>>  alias c clear
> >>>
> >>
> >> Ah, got it.  External commands cannot be used as a command for alias, so
> >> I added it exceptionally.
> >>
> >> Lianbo, is this OK?
> >>
> >>
> > Sorry for the late reply.
> >
> > This seems acceptable. But I just have one question, please see the
> comment
> > below.
> >
> >
> >>   From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00 2001
> >> From: Kazuhito Hagio 
> >> Date: Fri, 29 Sep 2023 11:58:04 +0900
> >> Subject: [PATCH] Make "clear" external command runnable without "!" and
> >>alias-able
> >>
> >> Make the "clear" external command runnable without an exclamation point
> >> ("!") for convenient.  Additionally, make it acceptable as a command
> >> string for alias exceptionally in external commands.
> >>
> >> Signed-off-by: Kazuhito Hagio 
> >> ---
> >>cmdline.c | 4 
> >>main.c| 3 ++-
> >>2 files changed, 6 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/cmdline.c b/cmdline.c
> >> index b7f919ae2279..65da04cbf9a5 100644
> >> --- a/cmdline.c
> >> +++ b/cmdline.c
> >> @@ -1833,6 +1833,10 @@ allocate_alias(int origin)
> >>  if (get_command_table_entry(args[2]))
> >>  found = TRUE;
> >>
> >> +   /* Accept the "clear" external command exceptionally. */
> >> +   if (STREQ(args[2], "clear"))
> >> +   found = TRUE;
> >>
> >
> > I added the debugging info here:
> >
> > +error(INFO, "args1->%s, args2->%s\n",args[1], args[2]);
> > +   /* Accept the "clear" external command exceptionally. */
> > +if (STREQ(args[2], "clear"))
> > +   found = TRUE;
> >
> > And I did not see any output information with the string "clear".
> > The variable 'found' won't be set to 'TRUE' unless it is initialized in
> the
> > alias_init() such as the "lsmod", right?
>
> No.  sorry, maybe I don't get your question... but this hunk is for
> something like:
>
>
This answers my question. Thank you, Kazu.


> crash> alias c clear
> alias: args1->c, args2->clear
> ORIGIN   ALIASCOMMAND
> runtime  cclear
> crash> c
>(I can confirm that the screen is cleared.)
>
> I don't intend to have it as a builtin alias.
>
>
Looks good to me. So, for the patch: Ack.

Thanks.
Lianbo



> Hope this help.
>
> Thanks,
> Kazu
>
>
> >
> > Other changes are fine to me.
> >
> > Thanks.
> > Lianbo
> >
> > +
> >>  if (!found) {
> >>  if (!strlen(args[2])) {
> >>  if (alias_exists(args[1])) {
> >> diff --git a/main.c b/main.c
> >> index 0c6e5958f3ad..4fd4ca57dbb2 100644
> >> --- a/main.c
> >> +++ b/main.c
> >> @@ -1043,7 +1043,8 @@ is_external_command(void)
> >>STREQ(cmd, "more") ||
> >>STREQ(cmd, "less") ||
> >>  STREQ(cmd, "echo") ||
> >> -STREQ(cmd, "ls")) {
> >> +   STREQ(cmd, "ls") ||
> >> +   STREQ(cmd, "clear")) {
> >>sprintf(command, "%s", cmd);
> >>for (i = 1; i < argcnt; i++) {
> >>strcat(command, " ");
> >> --
> >> 2.31.1
> >>
> >>
> >>
> >> On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁)
> >> mailto:k-hagio...@nec.com>> wrote:
> >>
> >> On 2023/09/29 9:58, Shijie Huang wrote:
> >> > Hi Kazu,
> >> >
> >> > 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
> >> >> 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.
> >> >
> >> > My final purpose is to use 'alias' to map the command to 'c':
> >> >
> >> > alias c clear
> >> >
> >>
> >> Ah, got it.  External commands cannot be used as a command for
> >> alias, so
> >> I added it exceptionally.
> >>
> >> Lianbo, is this OK?
> >>
> >> Sorry for the late reply.
> >>
> >> This seems acceptable. But I just have one question, please see the
> >> comment below.
> >>
> >>
> >>  From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00
> >> 2001
> >> From: Kazuhito Hagio mailto:k-hagio...@nec.com
> >>
> >> Date: Fri, 29 Sep 2023 11:58:04 +0900
> >> Subject: [PATCH] Make "clear" external command runnable without
> >> "!" and
> >>   alias-able
> >>
> >> Make the "clear" external command runnable without an exclamation
> >> 

Re: [Crash-utility] [PATCH] add clear command

2023-10-09 Thread 萩尾 一仁
On 2023/10/07 16:48, lijiang wrote:
> On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁) 
> wrote:
> 
>> On 2023/09/29 9:58, Shijie Huang wrote:
>>> Hi Kazu,
>>>
>>> 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
 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.
>>>
>>> My final purpose is to use 'alias' to map the command to 'c':
>>>
>>>  alias c clear
>>>
>>
>> Ah, got it.  External commands cannot be used as a command for alias, so
>> I added it exceptionally.
>>
>> Lianbo, is this OK?
>>
>>
> Sorry for the late reply.
> 
> This seems acceptable. But I just have one question, please see the comment
> below.
> 
> 
>>   From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00 2001
>> From: Kazuhito Hagio 
>> Date: Fri, 29 Sep 2023 11:58:04 +0900
>> Subject: [PATCH] Make "clear" external command runnable without "!" and
>>alias-able
>>
>> Make the "clear" external command runnable without an exclamation point
>> ("!") for convenient.  Additionally, make it acceptable as a command
>> string for alias exceptionally in external commands.
>>
>> Signed-off-by: Kazuhito Hagio 
>> ---
>>cmdline.c | 4 
>>main.c| 3 ++-
>>2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/cmdline.c b/cmdline.c
>> index b7f919ae2279..65da04cbf9a5 100644
>> --- a/cmdline.c
>> +++ b/cmdline.c
>> @@ -1833,6 +1833,10 @@ allocate_alias(int origin)
>>  if (get_command_table_entry(args[2]))
>>  found = TRUE;
>>
>> +   /* Accept the "clear" external command exceptionally. */
>> +   if (STREQ(args[2], "clear"))
>> +   found = TRUE;
>>
> 
> I added the debugging info here:
> 
> +error(INFO, "args1->%s, args2->%s\n",args[1], args[2]);
> +   /* Accept the "clear" external command exceptionally. */
> +if (STREQ(args[2], "clear"))
> +   found = TRUE;
> 
> And I did not see any output information with the string "clear".
> The variable 'found' won't be set to 'TRUE' unless it is initialized in the
> alias_init() such as the "lsmod", right?

No.  sorry, maybe I don't get your question... but this hunk is for 
something like:

crash> alias c clear
alias: args1->c, args2->clear
ORIGIN   ALIASCOMMAND
runtime  cclear
crash> c
   (I can confirm that the screen is cleared.)

I don't intend to have it as a builtin alias.

Hope this help.

Thanks,
Kazu


> 
> Other changes are fine to me.
> 
> Thanks.
> Lianbo
> 
> +
>>  if (!found) {
>>  if (!strlen(args[2])) {
>>  if (alias_exists(args[1])) {
>> diff --git a/main.c b/main.c
>> index 0c6e5958f3ad..4fd4ca57dbb2 100644
>> --- a/main.c
>> +++ b/main.c
>> @@ -1043,7 +1043,8 @@ is_external_command(void)
>>STREQ(cmd, "more") ||
>>STREQ(cmd, "less") ||
>>  STREQ(cmd, "echo") ||
>> -STREQ(cmd, "ls")) {
>> +   STREQ(cmd, "ls") ||
>> +   STREQ(cmd, "clear")) {
>>sprintf(command, "%s", cmd);
>>for (i = 1; i < argcnt; i++) {
>>strcat(command, " ");
>> --
>> 2.31.1
>>
>>
>>
>> On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁) 
>> mailto:k-hagio...@nec.com>> wrote:
>>
>> On 2023/09/29 9:58, Shijie Huang wrote:
>> > Hi Kazu,
>> >
>> > 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
>> >> 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.
>> >
>> > My final purpose is to use 'alias' to map the command to 'c':
>> >
>> >     alias c clear
>> >
>>
>> Ah, got it.  External commands cannot be used as a command for
>> alias, so
>> I added it exceptionally.
>>
>> Lianbo, is this OK?
>>
>> Sorry for the late reply.
>>
>> This seems acceptable. But I just have one question, please see the 
>> comment below.
>>
>>
>>  From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00
>> 2001
>> From: Kazuhito Hagio mailto:k-hagio...@nec.com>>
>> Date: Fri, 29 Sep 2023 11:58:04 +0900
>> Subject: [PATCH] Make "clear" external command runnable without
>> "!" and
>>   alias-able
>>
>> Make the "clear" external command runnable without an exclamation
>> point
>> ("!") for convenient.  Additionally, make it acceptable as a command
>> string for alias exceptionally in external commands.
>>
>> Signed-off-by: Kazuhito Hagio > >
>> ---
>>   cmdline.c | 4 
>>   main.c    | 3 ++-
>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/cmdline.c b/cmdline.c
>> index b7f919ae2279..65da04cbf9a5 100644
>> --- a/cmdline.c
>> +++ b/cmdline.c
>> @@ 

Re: [Crash-utility] [PATCH] add clear command

2023-10-07 Thread lijiang
On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁) 
wrote:

> On 2023/09/29 9:58, Shijie Huang wrote:
> > Hi Kazu,
> >
> > 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
> >> 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.
> >
> > My final purpose is to use 'alias' to map the command to 'c':
> >
> > alias c clear
> >
>
> Ah, got it.  External commands cannot be used as a command for alias, so
> I added it exceptionally.
>
> Lianbo, is this OK?
>
>
Sorry for the late reply.

This seems acceptable. But I just have one question, please see the comment
below.


>  From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00 2001
> From: Kazuhito Hagio 
> Date: Fri, 29 Sep 2023 11:58:04 +0900
> Subject: [PATCH] Make "clear" external command runnable without "!" and
>   alias-able
>
> Make the "clear" external command runnable without an exclamation point
> ("!") for convenient.  Additionally, make it acceptable as a command
> string for alias exceptionally in external commands.
>
> Signed-off-by: Kazuhito Hagio 
> ---
>   cmdline.c | 4 
>   main.c| 3 ++-
>   2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/cmdline.c b/cmdline.c
> index b7f919ae2279..65da04cbf9a5 100644
> --- a/cmdline.c
> +++ b/cmdline.c
> @@ -1833,6 +1833,10 @@ allocate_alias(int origin)
> if (get_command_table_entry(args[2]))
> found = TRUE;
>
> +   /* Accept the "clear" external command exceptionally. */
> +   if (STREQ(args[2], "clear"))
> +   found = TRUE;
>

I added the debugging info here:

+error(INFO, "args1->%s, args2->%s\n",args[1], args[2]);
+   /* Accept the "clear" external command exceptionally. */
+if (STREQ(args[2], "clear"))
+   found = TRUE;

And I did not see any output information with the string "clear".
The variable 'found' won't be set to 'TRUE' unless it is initialized in the
alias_init() such as the "lsmod", right?

Other changes are fine to me.

Thanks.
Lianbo

+
> if (!found) {
> if (!strlen(args[2])) {
> if (alias_exists(args[1])) {
> diff --git a/main.c b/main.c
> index 0c6e5958f3ad..4fd4ca57dbb2 100644
> --- a/main.c
> +++ b/main.c
> @@ -1043,7 +1043,8 @@ is_external_command(void)
>   STREQ(cmd, "more") ||
>   STREQ(cmd, "less") ||
> STREQ(cmd, "echo") ||
> -STREQ(cmd, "ls")) {
> +   STREQ(cmd, "ls") ||
> +   STREQ(cmd, "clear")) {
>   sprintf(command, "%s", cmd);
>   for (i = 1; i < argcnt; i++) {
>   strcat(command, " ");
> --
> 2.31.1
>
>
--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


Re: [Crash-utility] [PATCH] add clear command

2023-09-28 Thread 萩尾 一仁
On 2023/09/29 9:58, Shijie Huang wrote:
> Hi Kazu,
> 
> 在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:
>> 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.
> 
> My final purpose is to use 'alias' to map the command to 'c':
> 
>     alias c clear
> 

Ah, got it.  External commands cannot be used as a command for alias, so 
I added it exceptionally.

Lianbo, is this OK?


 From c9dc09e9c3e9b51664c555fd6dda71999c193ca8 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio 
Date: Fri, 29 Sep 2023 11:58:04 +0900
Subject: [PATCH] Make "clear" external command runnable without "!" and
  alias-able

Make the "clear" external command runnable without an exclamation point
("!") for convenient.  Additionally, make it acceptable as a command
string for alias exceptionally in external commands.

Signed-off-by: Kazuhito Hagio 
---
  cmdline.c | 4 
  main.c| 3 ++-
  2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/cmdline.c b/cmdline.c
index b7f919ae2279..65da04cbf9a5 100644
--- a/cmdline.c
+++ b/cmdline.c
@@ -1833,6 +1833,10 @@ allocate_alias(int origin)
if (get_command_table_entry(args[2]))
found = TRUE;

+   /* Accept the "clear" external command exceptionally. */
+   if (STREQ(args[2], "clear"))
+   found = TRUE;
+
if (!found) {
if (!strlen(args[2])) {
if (alias_exists(args[1])) {
diff --git a/main.c b/main.c
index 0c6e5958f3ad..4fd4ca57dbb2 100644
--- a/main.c
+++ b/main.c
@@ -1043,7 +1043,8 @@ is_external_command(void)
  STREQ(cmd, "more") ||
  STREQ(cmd, "less") ||
STREQ(cmd, "echo") ||
-STREQ(cmd, "ls")) {
+   STREQ(cmd, "ls") ||
+   STREQ(cmd, "clear")) {
  sprintf(command, "%s", cmd);
  for (i = 1; i < argcnt; i++) {
  strcat(command, " ");
-- 
2.31.1

--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


Re: [Crash-utility] [PATCH] add clear command

2023-09-28 Thread Shijie Huang

Hi Kazu,

在 2023/9/29 8:44, HAGIO KAZUHITO(萩尾 一仁) 写道:

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.


My final purpose is to use 'alias' to map the command to 'c':

   alias c clear




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")) {


I okay with this one.

could you please create a patch for it?


Thanks

Huang Shijie

--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


Re: [Crash-utility] [PATCH] add clear command

2023-09-28 Thread 萩尾 一仁
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 
> ---
> 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@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki