Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Aug 2013 09:23:09 -0600
From:      Ian Lepore <ian@FreeBSD.org>
To:        Glen Barber <gjb@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r254217 - head/sys/conf
Message-ID:  <1376407389.3320.209.camel@revolution.hippie.lan>
In-Reply-To: <201308111357.r7BDvF7H065442@svn.freebsd.org>
References:  <201308111357.r7BDvF7H065442@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 2013-08-11 at 13:57 +0000, Glen Barber wrote:
> Author: gjb
> Date: Sun Aug 11 13:57:14 2013
> New Revision: 254217
> URL: http://svnweb.freebsd.org/changeset/base/254217
> 
> Log:
>   Use realpath(1) to determine the location of the newvers.sh script,
>   since the current working directory might not be what is expected,
>   causing svn{,lite}version to fail to find ${0} (itself).
>   
>   Submitted by:	Dan Mack
> 
> Modified:
>   head/sys/conf/newvers.sh
> 
> Modified: head/sys/conf/newvers.sh
> ==============================================================================
> --- head/sys/conf/newvers.sh	Sun Aug 11 11:33:48 2013	(r254216)
> +++ head/sys/conf/newvers.sh	Sun Aug 11 13:57:14 2013	(r254217)
> @@ -96,7 +96,7 @@ for dir in /usr/bin /usr/local/bin; do
>  		# Run svnversion from ${dir} on this script; if return code
>  		# is not zero, the checkout might not be compatible with the
>  		# svnversion being used.
> -		${dir}/svnversion $(basename ${0}) >/dev/null 2>&1
> +		${dir}/svnversion $(realpath ${0}) >/dev/null 2>&1
>  		if [ $? -eq 0 ]; then
>  			svnversion=${dir}/svnversion
>  			break
> @@ -105,7 +105,7 @@ for dir in /usr/bin /usr/local/bin; do
>  done
>  
>  if [ -z "${svnversion}" ] && [ -x /usr/bin/svnliteversion ] ; then
> -	/usr/bin/svnliteversion $(basename ${0}) >/dev/null 2>&1
> +	/usr/bin/svnliteversion $(realpath ${0}) >/dev/null 2>&1
>  	if [ $? -eq 0 ]; then
>  		svnversion=/usr/bin/svnliteversion
>  	else

This is still not working for me.  I don't see how it could be working
properly for anyone.

The newvers.sh isn't run from the make rules, it's sourced into the
rules.  In that context, ${0} appears to resolve to simply "sh" or
"/bin/sh" (depending on host OS version) not the name of the script that
was sourced.  Here's a minimal example:

        root@wand:/tmp # cat /tmp/foo
        #!/bin/sh -
        echo ${0}
        
        root@wand:/tmp # cat /tmp/Makefile 
        all:
                @echo "Sourcing /tmp/foo..."; \
                . /tmp/foo
        
        root@wand:/tmp # make
        Sourcing /tmp/foo...
        /bin/sh

There are other references to $0 within newvers.sh, and if you add a
'set -x' to the beginning of the script you can see that they all
resolve to /bin/sh, which seems to imply that there's some stuff that's
working by accident in that script when it's sourced in.

-- Ian





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1376407389.3320.209.camel>