svn commit: r254217 - head/sys/conf

Glen Barber gjb at FreeBSD.org
Tue Aug 13 17:53:39 UTC 2013


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 at nucleus:~ % cat foo1.sh foo2.sh
#!/bin/sh
echo ${0}
. foo2.sh
#!/bin/sh
echo ${0}
gjb at 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

-------------- next part --------------
Index: head/sys/conf/newvers.sh
===================================================================
--- head/sys/conf/newvers.sh	(revision 254284)
+++ head/sys/conf/newvers.sh	(working copy)
@@ -96,7 +96,7 @@
 		# 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 +105,7 @@
 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20130813/415ff5ac/attachment.sig>


More information about the svn-src-head mailing list