if (res == 0) {
if (loop == 0) {
debug("%s: No match\n", data);
- return 1;
} else {
- break;
+ debug("## MATCH ## %s\n", data);
}
+ break;
}
- debug("## MATCH ## %s\n", data);
-
if (!s)
return 1;
" - For each substring matching the regular expression <r> in the\n"
" string <t>, substitute the string <s>. The result is\n"
" assigned to <name>. If <t> is not supplied, use the old\n"
- " value of <name>\n"
+ " value of <name>. If no substring matching <r> is found in <t>,\n"
+ " assign <t> to <name>.\n"
"setexpr name sub r s [t]\n"
" - Just like gsub(), but replace only the first matching substring"
#endif
string <t>, substitute the string <s>.
The result is assigned to <name>.
If <t> is not supplied, use the old value of <name>.
+ If no substring matching <r> is found in <t>, assign <t> to <name>.
setexpr name sub <r> <s> [<t>]
Just like gsub(), but replace only the first matching substring
val = env_get("mary");
ut_asserteq_str("this is a test", val);
+ /* No match */
+ ut_assertok(run_command("setenv fred 'this is a test'", 0));
+ ut_assertok(run_command("setenv mary ''", 0));
+ ut_assertok(run_command("setexpr fred gsub us is \"${fred}\"", 0));
+ ut_assertok(run_command("setexpr mary gsub us is \"${fred}\"", 0));
+ val = env_get("fred");
+ ut_asserteq_str("this is a test", val);
+ val = env_get("mary");
+ ut_asserteq_str("this is a test", val);
+
unmap_sysmem(buf);
return 0;