[OE-core] [PATCH 1/1] oe-init-build-env, scripts/oe-buildenv-internal: add error detecting for $BDIR

Cui, Dexuan dexuan.cui at intel.com
Thu Aug 4 02:25:18 UTC 2011

Darren Hart wrote on 2011-08-03:
> On 08/02/2011 11:46 PM, Cui, Dexuan wrote:
>> Hi Darren, thanks for the suggestion! I considered the idea too,
>> however, if we use the idea, it looks not that simple to gracefully
>> and concisely handle the case if a user (by accident or by prank)
>> passes / as $1 here, i.e., "readlink -f" would fail. So I didn't do
>> that.
> Hi Dexuan, 
> I had not considered that case, good catch. I can't think of a valid
> use case for BDIR="/". Not only are write permissions unlikely, but

> the build would conflict with /tmp as well.
> if [ "$BDIR" == "/" ]; then
> 	echo "ERROR: / is not supported as a build directory."
> 	exit 1
> fi
> BDIR=${BDIR%/}
Hi Darren,
This seems good to me.
Looks ${BDIR%/} can only remove one trailing slash. Do we need to consider more-than-one-slashes, e.g., $BDIR is /home/poky/build///? :-)   (We could use sed:  BDIR=`echo $BDIR | sed -re 's|/+$||'` , but I'm not sure if it deserves the complexity)
Darren, could you please help to make a patch? 
I really have few experience about how to validate a user's input. :-)

> I would be happy with something like the above (untested). It seems a
> lot more clear and direct to me.
> In any case, I don't see any reason to bail out and ask the user to
> remove a trailing slash. We should just do this and move on. There is
> no semantic difference from the user's perspective, and the blame is
> to be placed on readlink, not the user.
I agree.

-- Dexuan

More information about the Openembedded-core mailing list