diff mbox series

[1/3] cli_hush.c: refactor handle_dollar() to prepare for cmd_call

Message ID 20200925111942.4629-2-rasmus.villemoes@prevas.dk
State Superseded
Delegated to: Tom Rini
Headers show
Series add "call" command | expand

Commit Message

Rasmus Villemoes Sept. 25, 2020, 11:19 a.m. UTC
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(-)

Comments

Wolfgang Denk Sept. 25, 2020, 1:02 p.m. UTC | #1
Dear Rasmus,

In message <20200925111942.4629-2-rasmus.villemoes@prevas.dk> you wrote:
> 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.

I won't comment on these and the other patches - you know my
opinion: instead of hacking the current code, we should 1) come up
with a plan and 2) update.

Please consider this a soft-NAK ;-)

Best regards,

Wolfgang Denk
diff mbox series

Patch

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;