[PATCH] setupEnvironment() check that PATH exists before appending otherwise create PATH
Jesse Ahrens
jnahrens at fb.com
Fri Aug 29 08:24:20 UTC 2014
>On Thu, 2014-08-28 at 06:59 -0700, Jesse Ahrens wrote:
>> ---
>> anaconda | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/anaconda b/anaconda
>> index 7fb9370..8a275fb 100755
>> --- a/anaconda
>> +++ b/anaconda
>> @@ -542,7 +542,10 @@ def setupEnvironment():
>> os.environ["LVM_SUPPRESS_FD_WARNINGS"] = "1"
>>
>> # make sure we have /sbin and /usr/sbin in our path
>> - os.environ["PATH"] += ":/sbin:/usr/sbin"
>> + if os.environ["PATH"]:
>> + os.environ["PATH"] += ":/sbin:/usr/sbin"
>> + else:
>> + os.environ["PATH"] = "/sbin:/usr/sbin"
>I don't undertand this change. If there's no $PATH env. variable, the
>'if os.environ["PATH"]:' line will cause a traceback. Did you mean
>something like 'if "PATH" in os.environ"? In that case something like
>this would be best, I think:
>
>os.environ["PATH"] = os.environ.get("PATH", "") + ":/sbin:/usr/sbin"
>
>--
>Vratislav Podzimek
>
>Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic
Yes, an Œif in¹ would have been more pythonic. Your solution is cleanest.
More information about the anaconda-patches
mailing list