Hi Arvind,

On Sat, Mar 10, 2018 at 11:11:58AM -0500, Arvind Prasanna wrote:
> It is possible to source edksetup.sh from another script. If the
> calling/sourcing script has any positional parameters set, those are
> incorrectly accounted for in edksetup.sh while sourcing it resulting in
> the the help section always being shown. This patch updates the help
> section advising the user about these set positional parameters so they
> can be unset prior to sourcing edksetup.sh.

This is really just one of the unpleasantries of sourcing shell
scripts.

Since the current script could only ever work with bash anyway (and
not sh, dash, ...) I don't know that we could do much better - and
there's nothing about the problem that is specific to this script.

As an aside, since we _know_ this only works on bash, you can also
make use of the bash side effect that if you pass any arguments to the
sourced script, it gets its own copies of $#, $0, $1 and so on.

For ancient backwards compatility, the parameter BaseTools is ignored
if provided on the command line. So you could always just use
  edksetup.sh BaseTools

Alternatively, you can use
  edksetup.sh --reconfig
which also ensures you are always using the latest toolchain
templates.

Regards,

Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Arvind Prasanna <[email protected]>
> ---
>  edksetup.sh | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/edksetup.sh b/edksetup.sh
> index 93d6525..a3d5560 100755
> --- a/edksetup.sh
> +++ b/edksetup.sh
> @@ -42,6 +42,8 @@ function HelpMsg()
>    echo Please note: This script must be \'sourced\' so the environment can 
> be changed.
>    echo ". $SCRIPTNAME"
>    echo "source $SCRIPTNAME"
> +  echo "If this script is being sourced from another script, please ensure 
> that the"
> +  echo "sourcing/calling script has no set postional parameters."
>  }
>  
>  function SetWorkspace()
> -- 
> 2.7.4
> 
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to