]> git.proxmox.com Git - mirror_edk2.git/blobdiff - edksetup.sh
Fix the return value bug when updating public key database variable failure.
[mirror_edk2.git] / edksetup.sh
index c4fe9a60eff70a97a7b36d8b868cfa15224ece29..0b7e33fd77769eefa62b30278003ef54830b31ca 100755 (executable)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
 # Please reference edk2 user manual for more detail descriptions at https://edk2.tianocore.org/files/documents/64/494/EDKII_UserManual.pdf
 #
 
-if [ \
-     -z "$1" -o \
-     "$1" = "-?" -o \
-     "$1" = "-h" -o \
-     "$1" = "--help" \
-   ]
-then
-  echo BaseTools Usage: \'. edksetup.sh\'
-  echo
+function HelpMsg()
+{
   echo Please note: This script must be \'sourced\' so the environment can be changed.
-  echo \(Either \'. edksetup.sh\' or \'source edksetup.sh\'\)
-  return
+  echo ". edksetup.sh" 
+  echo "source edksetup.sh"
+  return 1
+}
+
+function SetupEnv()
+{
+  if [ -z "$WORKSPACE" ]
+  then
+    . BaseTools/BuildEnv $*
+  else
+    . $WORKSPACE/BaseTools/BuildEnv $*
+  fi
+}
+
+function SourceEnv()
+{
+  if [ \
+       "$1" = "-?" -o \
+       "$1" = "-h" -o \
+       "$1" = "--help" \
+     ]
+  then
+    HelpMsg
+  else
+    SetupEnv "$*"
+  fi
+}
+
+if [ $# -gt 1 ]
+then
+  HelpMsg
+elif [ $# -eq 1 ] && [ "$1" != "BaseTools" ]
+then
+  HelpMsg
 fi
 
-if [ -z "$WORKSPACE" ]
+RETVAL=$?
+if [ $RETVAL -ne 0 ]
 then
-  . BaseTools/BuildEnv $*
-else
-  . $WORKSPACE/BaseTools/BuildEnv $*
+  return $RETVAL
 fi
 
+SourceEnv "$*"