All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: u-boot@lists.denx.de
Subject: [PATCH v2 1/3] cli_hush.c: refactor handle_dollar() to prepare for "run with arguments"
Date: Wed,  7 Oct 2020 09:20:50 +0200	[thread overview]
Message-ID: <20201007072052.28200-2-rasmus.villemoes@prevas.dk> (raw)
In-Reply-To: <20201007072052.28200-1-rasmus.villemoes@prevas.dk>

A later patch will add handling of $1 through $9 as well as $#, using
the same SPECIAL_VAR_SYMBOL handling as is currently used for $?. So
move that case to an explicit #ifdef __U_BOOT__ branch, and
consolidate a few of the #ifndef __U_BOOT__ cases, making it easier to
see the original hush code.

No functional change.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 common/cli_hush.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/cli_hush.c b/common/cli_hush.c
index 5b1f119074..072b871f1e 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -2863,6 +2863,16 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
 		advance = 1;
 #endif
 	} else switch (ch) {
+#ifdef __U_BOOT__
+		case '?':
+			ctx->child->sp++;
+			b_addchr(dest, SPECIAL_VAR_SYMBOL);
+			b_addchr(dest, '$');
+			b_addchr(dest, '?');
+			b_addchr(dest, SPECIAL_VAR_SYMBOL);
+			advance = 1;
+			break;
+#endif
 #ifndef __U_BOOT__
 		case '$':
 			b_adduint(dest,getpid());
@@ -2872,20 +2882,10 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
 			if (last_bg_pid > 0) b_adduint(dest, last_bg_pid);
 			advance = 1;
 			break;
-#endif
 		case '?':
-#ifndef __U_BOOT__
 			b_adduint(dest,last_return_code);
-#else
-			ctx->child->sp++;
-			b_addchr(dest, SPECIAL_VAR_SYMBOL);
-			b_addchr(dest, '$');
-			b_addchr(dest, '?');
-			b_addchr(dest, SPECIAL_VAR_SYMBOL);
-#endif
 			advance = 1;
 			break;
-#ifndef __U_BOOT__
 		case '#':
 			b_adduint(dest,global_argc ? global_argc-1 : 0);
 			advance = 1;
-- 
2.23.0

  reply	other threads:[~2020-10-07  7:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 11:19 [PATCH 0/3] add "call" command Rasmus Villemoes
2020-09-25 11:19 ` [PATCH 1/3] cli_hush.c: refactor handle_dollar() to prepare for cmd_call Rasmus Villemoes
2020-09-25 13:02   ` Wolfgang Denk
2020-09-25 11:19 ` [PATCH 2/3] cli_hush.c: add "call" command Rasmus Villemoes
2020-09-25 13:18   ` Rasmus Villemoes
2020-09-26  8:37     ` Wolfgang Denk
2020-09-25 11:19 ` [PATCH 3/3] ut: add small hush tests Rasmus Villemoes
2020-09-25 11:52 ` [PATCH 0/3] add "call" command Heinrich Schuchardt
2020-09-25 12:36   ` Rasmus Villemoes
2020-09-25 13:09   ` Wolfgang Denk
2020-09-25 13:38     ` Rasmus Villemoes
2020-09-25 13:38     ` Heinrich Schuchardt
2020-09-25 13:51       ` Rasmus Villemoes
2020-09-26  8:55         ` Wolfgang Denk
2020-09-26  8:51       ` Wolfgang Denk
2020-09-26 10:39         ` Heinrich Schuchardt
2020-09-26 14:13           ` Wolfgang Denk
2020-09-25 12:59 ` Wolfgang Denk
2020-09-25 14:40   ` Simon Glass
2020-09-26 14:02     ` Wolfgang Denk
2020-09-29 17:45       ` Tom Rini
2020-09-30 11:46         ` Wolfgang Denk
2020-10-07  7:20 ` [PATCH v2 0/3] allow positional arguments with "run" Rasmus Villemoes
2020-10-07  7:20   ` Rasmus Villemoes [this message]
2020-10-12  3:34     ` [PATCH v2 1/3] cli_hush.c: refactor handle_dollar() to prepare for "run with arguments" Simon Glass
2020-10-07  7:20   ` [PATCH v2 2/3] allow positional arguments with "run" command Rasmus Villemoes
2020-10-12  3:34     ` Simon Glass
2020-10-12  7:06       ` Rasmus Villemoes
2020-10-15 15:05         ` Simon Glass
2020-10-15 22:06           ` Rasmus Villemoes
2020-10-19  7:31             ` Wolfgang Denk
2020-10-19  8:31               ` Rasmus Villemoes
2020-10-19  8:49                 ` Wolfgang Denk
2020-10-07  7:20   ` [PATCH v2 3/3] ut: add small hush tests Rasmus Villemoes
2020-10-12  3:34     ` Simon Glass
2020-11-05  7:25   ` [PATCH v2 0/3] allow positional arguments with "run" Rasmus Villemoes
2020-11-06 20:52     ` Tom Rini
2020-11-08 13:28       ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201007072052.28200-2-rasmus.villemoes@prevas.dk \
    --to=rasmus.villemoes@prevas.dk \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.