common: cli_hush: Restore clear local variable support
The u-boot hush shell doesn’t support the unset command to clear a
variable and therefore an empty value ("c=") should be a valid value
for the set_local_var function to clear the variable. This partial
reverts commit aa72252963
("common: cli_hush: avoid dead code") and
only checks for a `=` in the string. Additionally explicit call the
unset_local_var function to remove the variable if the value is empty.
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
d30fbabade
commit
930ef10992
1 changed files with 7 additions and 1 deletions
|
@ -2171,12 +2171,18 @@ int set_local_var(const char *s, int flg_export)
|
||||||
* NAME=VALUE format. So the first order of business is to
|
* NAME=VALUE format. So the first order of business is to
|
||||||
* split 's' on the '=' into 'name' and 'value' */
|
* split 's' on the '=' into 'name' and 'value' */
|
||||||
value = strchr(name, '=');
|
value = strchr(name, '=');
|
||||||
if (value == NULL || *(value + 1) == 0) {
|
if (!value) {
|
||||||
free(name);
|
free(name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*value++ = 0;
|
*value++ = 0;
|
||||||
|
|
||||||
|
if (!*value) {
|
||||||
|
unset_local_var(name);
|
||||||
|
free(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for(cur = top_vars; cur; cur = cur->next) {
|
for(cur = top_vars; cur; cur = cur->next) {
|
||||||
if(strcmp(cur->name, name)==0)
|
if(strcmp(cur->name, name)==0)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue