Re: [PATCH] add clear command

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

 



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 <k-hagio-ab@xxxxxxx>
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@xxxxxxx>
---
  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@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