From owner-svn-src-all@FreeBSD.ORG Tue Aug 13 20:10:00 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6696C6CA; Tue, 13 Aug 2013 20:10:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3715421C1; Tue, 13 Aug 2013 20:09:59 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1V9Kuk-000Pqu-To; Tue, 13 Aug 2013 20:09:59 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r7DK9uUt036166; Tue, 13 Aug 2013 14:09:56 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+5vrxczughjg8GeSjABh7O Subject: Re: svn commit: r254217 - head/sys/conf From: Ian Lepore To: Glen Barber In-Reply-To: <20130813175335.GR2432@glenbarber.us> References: <201308111357.r7BDvF7H065442@svn.freebsd.org> <1376407389.3320.209.camel@revolution.hippie.lan> <20130813153222.GL2432@glenbarber.us> <1376413337.3320.224.camel@revolution.hippie.lan> <20130813171302.GQ2432@glenbarber.us> <1376415112.3320.229.camel@revolution.hippie.lan> <20130813175335.GR2432@glenbarber.us> Content-Type: multipart/mixed; boundary="=-dS1c8vzyNz4qYYQw5eOu" Date: Tue, 13 Aug 2013 14:09:56 -0600 Message-ID: <1376424596.3320.242.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Aug 2013 20:10:00 -0000 --=-dS1c8vzyNz4qYYQw5eOu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Tue, 2013-08-13 at 13:53 -0400, Glen Barber wrote: > On Tue, Aug 13, 2013 at 11:31:52AM -0600, Ian Lepore wrote: > > I'm not even sure what $0 *should* expand to in a script that was > > sourced in. The manpage doesn't say anything meaningful to me about it. > > Maybe it's a kind of "indeterminate results" thing which is pretty much > > what we're seeing. > > > > When the file is sourced, it should expand to the name of the file > sourcing the file. > > gjb@nucleus:~ % cat foo1.sh foo2.sh > #!/bin/sh > echo ${0} > . foo2.sh > #!/bin/sh > echo ${0} > gjb@nucleus:~ % sh ./foo1.sh > ./foo1.sh > ./foo1.sh > > > I was thinking that $(realpath ${PARAMFILE}) might be a good way to tap > > dance around the problem, but PARAMFILE can be set by default from > > $SYSDIR and it's not clear to me that that'll always be right either. > > > > Can you please try the attached patch? As with my prior tests, this > works for me... > > Glen > That didn't work, because $SYSDIR is derived from $0 which is the root of the problem. The attached works, and seems reasonable to me (it's your changes + passing in SYSDIR from the one place where newvers.sh is sourced rather than running it by name). -- Ian --=-dS1c8vzyNz4qYYQw5eOu Content-Disposition: inline; filename="newvers.sh.diff2.txt" Content-Type: text/plain; name="newvers.sh.diff2.txt"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: include/Makefile =================================================================== --- include/Makefile (revision 254281) +++ include/Makefile (working copy) @@ -108,6 +108,7 @@ osreldate.h: ${.CURDIR}/../sys/conf/newvers.sh ${. ${.CURDIR}/Makefile @${ECHO} creating osreldate.h from newvers.sh @MAKE=${MAKE}; \ + SYSDIR=${.CURDIR}/../sys; \ PARAMFILE=${.CURDIR}/../sys/sys/param.h; \ . ${.CURDIR}/../sys/conf/newvers.sh; \ echo "$$COPYRIGHT" > osreldate.h; \ Index: sys/conf/newvers.sh =================================================================== --- sys/conf/newvers.sh (revision 254281) +++ sys/conf/newvers.sh (working copy) @@ -38,8 +38,11 @@ if [ "X${BRANCH_OVERRIDE}" != "X" ]; then fi RELEASE="${REVISION}-${BRANCH}" VERSION="${TYPE} ${RELEASE}" -SYSDIR=$(dirname $0)/.. +if [ "X${SYSDIR}" = "X" ] ;then + SYSDIR=$(dirname $0)/.. +fi + if [ "X${PARAMFILE}" != "X" ]; then RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \ ${PARAMFILE}) @@ -96,7 +99,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 $(realpath ${0}) >/dev/null 2>&1 + ${dir}/svnversion ${SYSDIR}/Makefile >/dev/null 2>&1 if [ $? -eq 0 ]; then svnversion=${dir}/svnversion break @@ -105,7 +108,7 @@ for dir in /usr/bin /usr/local/bin; do done if [ -z "${svnversion}" ] && [ -x /usr/bin/svnliteversion ] ; then - /usr/bin/svnliteversion $(realpath ${0}) >/dev/null 2>&1 + /usr/bin/svnliteversion ${SYSDIR}/Makefile >/dev/null 2>&1 if [ $? -eq 0 ]; then svnversion=/usr/bin/svnliteversion else --=-dS1c8vzyNz4qYYQw5eOu--