[U-Boot] [PATCH 6/6] hush: add some tests for quoting

Rabin Vincent rabin at rab.in
Wed Oct 29 23:21:42 CET 2014


Add a couple of tests for quoting.  The indirect variable read test is
a fixed version of the following expression from Fedora ARM's boot.scr.
This unfixed expression stopped working after fe9ca3d ("hush: fix some
quoted variable expansion issues"):

 setenv catcat setenv catout\;'setenv catX "setenv catout '\\\\\\\''\$\$catin'\\\\\\\''"' \; run catX

Signed-off-by: Rabin Vincent <rabin at rab.in>
---
 test/command_ut.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/command_ut.c b/test/command_ut.c
index 926573a..21804a4 100644
--- a/test/command_ut.c
+++ b/test/command_ut.c
@@ -193,6 +193,16 @@ static int do_ut_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	assert(run_command("'", 0) == 1);
 
+	assert(run_command("setenv ut_var '\"'; setenv ut_var2 \"${ut_var}\"", 0) == 0);
+	assert(!strcmp(getenv("ut_var2"), "\""));
+
+	assert(run_command("setenv ut_catcat setenv ut_catout\\;setenv ut_catX setenv ut_catout \\\\\\\\\\\\\\\"\\$\\$ut_catin\\\\\\\\\\\\\\\" \\; run ut_catX", 0) == 0);
+	assert(run_command("setenv ut_pointer '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20'", 0) == 0);
+	assert(run_command("setenv ut_catin ut_pointer", 0) == 0);
+	assert(run_command("run ut_catcat", 0) == 0);
+	assert(getenv("ut_catout"));
+	assert(!strcmp(getenv("ut_catout"), "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"));
+
 	printf("%s: Everything went swimmingly\n", __func__);
 	return 0;
 }
-- 
2.1.1



More information about the U-Boot mailing list