On Tue, Oct 10, 2023 at 8:31 AM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
On 2023/10/07 16:48, lijiang wrote:
> On Fri, Sep 29, 2023 at 12:30 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@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 <k-hagio-ab@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 <k-hagio-ab@nec.com>
>> ---
>>    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   ALIAS    COMMAND
runtime  c        clear
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(萩尾 一仁)
>> <k-hagio-ab@nec.com <mailto:k-hagio-ab@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 <k-hagio-ab@nec.com <mailto:k-hagio-ab@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 <k-hagio-ab@nec.com
>>     <mailto:k-hagio-ab@nec.com>>
>>     ---
>>       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
>>