
Hi Rabin,
On 29 October 2014 16:21, Rabin Vincent rabin@rab.in wrote:
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@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);
Can we reduce this down to 3-4 numbers for easier maintenance? Or do the 20 numbers buy us something?
Also did you test this with the simple cli parser too?
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
Regards, Simon