The colon separator is included at the end of $NEWPATHS so it should not be possible for any false positives.
The intention of the patch was to avoid $PATH growing when rerunning oe-init-build-env in the same directory multiple times. I only match at the start of $PATH as I wanted to maintain the current functionality that guarantees that the paths are added to the beginning of $PATH and therefore searched before anything else. I did not want to go into analyzing $PATH which would have been needed to remove paths for other build trees. Also, I do not actually see this as possible since the static parts of the added paths (/scripts and /bin/) are to generic to be able to remove those paths without the risk of accidentally removing something unrelated. However, one thing that can easily be done is to instead reorder “$SOMEPATHS:$NEWPATHS$SOMEOTHERPATHS” to “$NEWPATHS$SOMEPATHS:$SOMEOTHERPATHS”. That should maintain the property of having the new paths at the beginning, while at the same time not grow $PATH unnecessarily if the paths are already present, but preceded by some other paths. I will provide a second version of the patch with the relevant part changed to: # Make sure our paths are at the beginning of $PATH NEWPATHS="${OEROOT}/scripts:$BITBAKEDIR/bin:" PATH=$NEWPATHS$(echo $PATH | sed -e "s|:$NEWPATHS|:|g" -e "s|^$NEWPATHS||") unset BITBAKEDIR NEWPATHS //Peter From: kerg...@gmail.com [mailto:kerg...@gmail.com] On Behalf Of Chris Larson Sent: den 9 april 2013 00:40 To: Paul Eggleton Cc: Trevor Woerner; Peter Kjellerstedt; Patches and discussions about the oe-core layer Subject: Re: [OE-core] [PATCH 2/3] oe-buildenv-internal: Only add to $PATH if needed On Mon, Apr 8, 2013 at 10:48 AM, Paul Eggleton <paul.eggle...@linux.intel.com<mailto:paul.eggle...@linux.intel.com>> wrote: On Monday 08 April 2013 13:31:50 Trevor Woerner wrote: > On Fri, Apr 5, 2013 at 12:59 PM, Peter Kjellerstedt > <peter.kjellerst...@axis.com<mailto:peter.kjellerst...@axis.com>> wrote: > > +[ "${PATH#$NEWPATHS}" != "$PATH" ] || PATH="$NEWPATHS$PATH" > > This is certainly a welcome addition in functionality, but it relies > on the pattern remaining at the start of the PATH (i.e. the user > hasn't played with PATH in any way). Could we not use the > ${parameter/pattern/string} parameter expansion instead (e.g. > "${PATH/$NEWPATHS/}") so it doesn't matter whether the user has > further modified the PATH? Unfortunately I think this is specific to bash, so it may not be portable. Maybe the equivalent can be achieved with sed however. Also, neither version matches the : separator, which means we could in theory get false positive matches. -- Christopher Larson
_______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core