[PATCH v2 1/3] cli_hush.c: refactor handle_dollar() to prepare for "run with arguments"
Rasmus Villemoes
rasmus.villemoes at prevas.dk
Wed Oct 7 09:20:50 CEST 2020
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 at 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
More information about the U-Boot
mailing list