ShellPkg/Application: Fix ">v" cannot update environment variable

When ">v" is used to redirect the command output to environment
variable (e.g.: "echo xxx >v yyy"), we only called SetVariable()
to update the variable storage but forgot to update the cached
environment variables in gShellEnvVarList.
When updating the variable storage, the existing code unnecessary
saved the ending NULL character into variable storage.

The patch fixes all the above issues.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
This commit is contained in:
Chen A Chen
2016-12-06 13:56:46 +08:00
committed by Ruiyu Ni
parent 8537bd7ef6
commit c5c994c573
3 changed files with 142 additions and 44 deletions

View File

@ -2872,8 +2872,8 @@ InternalEfiShellSetEnv(
);
if (!EFI_ERROR (Status)) {
Status = Volatile
? SHELL_SET_ENVIRONMENT_VARIABLE_V(Name, StrSize(Value), Value)
: SHELL_SET_ENVIRONMENT_VARIABLE_NV(Name, StrSize(Value), Value);
? SHELL_SET_ENVIRONMENT_VARIABLE_V (Name, StrSize (Value) - sizeof (CHAR16), Value)
: SHELL_SET_ENVIRONMENT_VARIABLE_NV (Name, StrSize (Value) - sizeof (CHAR16), Value);
if (EFI_ERROR (Status)) {
ShellRemvoeEnvVarFromList(Name);
}