Subject: Re: toolchain/36048: [dM] build.sh vs . in $PATH
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Alan Barrett <apb@cequrux.com>
List: netbsd-bugs
Date: 03/22/2007 19:10:03
The following reply was made to PR toolchain/36048; it has been noted by GNATS.

From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: netbsd-bugs@NetBSD.org
Subject: Re: toolchain/36048: [dM] build.sh vs . in $PATH
Date: Thu, 22 Mar 2007 21:06:11 +0200

 On Tue, 20 Mar 2007, der Mouse wrote:
 > >How-To-Repeat:
 > 	env PATH=.:$PATH build.sh ... build
 > 	(or "distribution", or anything else that implies "build").
 
 Does this patch look OK?
 
 Index: build.sh
 ===================================================================
 --- build.sh	19 Feb 2007 14:20:11 -0000	1.162
 +++ build.sh	22 Mar 2007 19:04:19 -0000
 @@ -69,6 +69,11 @@
  	${runcmd} echo "===> $@" | tee -a "${results}"
  }
  
 +warning()
 +{
 +	statusmsg "Warning: $@"
 +}
 +
  # Find a program in the PATH
  find_in_PATH()
  {
 @@ -793,6 +798,23 @@
  	export MAKEFLAGS MACHINE MACHINE_ARCH
  }
  
 +sanitycheck()
 +{
 +	# If the PATH contains any non-absolute components (including,
 +	# but not limited to, "." or ""), then complain.  This is fatal
 +	# if expert mode is not in effect.
 +	#
 +	case ":${PATH}:/" in
 +	*:[!/]*)
 +		if ${do_expertmode}; then
 +			warning "PATH contains non-absolute components"
 +		else
 +			bomb "PATH must not contain non-absolute components"
 +		fi
 +		;;
 +	esac
 +}
 +
  rebuildmake()
  {
  	# Test make source file timestamps against installed ${toolprefix}make
 @@ -1142,6 +1164,8 @@
  	_args=$@
  	parseoptions "$@"
  
 +	sanitycheck
 +
  	build_start=$(date)
  	statusmsg "${progname} command: $0 $@"
  	statusmsg "${progname} started: ${build_start}"