[edk2] [BugFix] ShellPkg: UefiShellLevel1CommandLib: Fix a logic issue about "if /i"

Zane Zhange posted 1 patch 6 years, 1 month ago
Failed in applying to current master (apply log)
ShellPkg/Library/UefiShellLevel1CommandsLib/If.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[edk2] [BugFix] ShellPkg: UefiShellLevel1CommandLib: Fix a logic issue about "if /i"
Posted by Zane Zhange 6 years, 1 month ago
From: zane66 <zheng.zhang1@hp.com>

Hello All,


It is my first time to commit my change on github, there might be some errors in this email. But my change actually fixed the issue about "if /i" in Uefi Shell. Thanks.

Github Reference URL : https://github.com/zane66/edk2/tree/zane66/master

Use this shell script to duplicate this issue:
if /i /s "ax" ne "aX" then
  echo "Not Equal"
fi
The origin code will echo "Not Equal". This change can fix this issue.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zane Zhang <zheng.zhang1@hp.com>
---
 ShellPkg/Library/UefiShellLevel1CommandsLib/If.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index 35c5ca6835..94162b2dae 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -141,7 +141,7 @@ TestOperation (
       //
       // string compare
       //
-      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) > 0) || (StringCompare(&Compare1, &Compare2) > 0)) {
+      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) > 0) || (!CaseInsensitive && StringCompare(&Compare1, &Compare2) > 0)) {
         return (TRUE);
       }
     } else {
@@ -175,7 +175,7 @@ TestOperation (
       //
       // string compare
       //
-      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) < 0) || (StringCompare(&Compare1, &Compare2) < 0)) {
+      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) < 0) || (!CaseInsensitive && StringCompare(&Compare1, &Compare2) < 0)) {
         return (TRUE);
       }
     } else {
@@ -209,7 +209,7 @@ TestOperation (
       //
       // string compare
       //
-      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) == 0) || (StringCompare(&Compare1, &Compare2) == 0)) {
+      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) == 0) || (!CaseInsensitive && StringCompare(&Compare1, &Compare2) == 0)) {
         return (TRUE);
       }
     } else {
@@ -236,7 +236,7 @@ TestOperation (
       //
       // string compare
       //
-      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) != 0) || (StringCompare(&Compare1, &Compare2) != 0)) {
+      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) != 0) || (!CaseInsensitive && StringCompare(&Compare1, &Compare2) != 0)) {
         return (TRUE);
       }
     } else {
@@ -264,7 +264,7 @@ TestOperation (
       //
       // string compare
       //
-      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) >= 0) || (StringCompare(&Compare1, &Compare2) >= 0)) {
+      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) >= 0) || (!CaseInsensitive && StringCompare(&Compare1, &Compare2) >= 0)) {
         return (TRUE);
       }
     } else {
@@ -298,7 +298,7 @@ TestOperation (
       //
       // string compare
       //
-      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) <= 0) || (StringCompare(&Compare1, &Compare2) <= 0)) {
+      if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) <= 0) || (!CaseInsensitive && StringCompare(&Compare1, &Compare2) <= 0)) {
         return (TRUE);
       }
     } else {
-- 
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel