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

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

Attachment: pgpcH0dPCZogl.pgp
Description: PGP signature

Reply via email to