[csw-maintainers] finding the absolute path of a shell script, was: Re: Fwd: [ccache] solaris compile error

rupert THURNER rupert at opencsw.org
Wed May 26 22:39:47 CEST 2010


On Wed, May 26, 2010 at 20:28, Sebastian Kayser <skayser at opencsw.org> wrote:
> * rupert THURNER <rupert at opencsw.org> wrote:
>> great, that worked. do we have a trick to make the test script work as
>> well? it contains "pwd" (which gives "trunk") to call the freshly
>> compiled ccache (which is deep in th ework directory), so the result
>> is:
>>
>> gmake[3]: Entering directory
>> `/home/rupert/mgar/pkg/ccache/trunk/work/solaris9-sparc/build-isa-sparcv8/ccache-3.0pre1'
>> CC='/opt/studio/SOS12/SUNWspro/bin/cc' ./test.sh
>> starting testsuite base
>> ./test.sh: /home/rupert/mgar/pkg/ccache/trunk/ccache: not found
>> SUITE: "base", TEST: "" - Expected "cache hit (preprocessed)" to be 0, got
>> ./test.sh: /home/rupert/mgar/pkg/ccache/trunk/ccache: not found
>> TEST FAILED
>
> I get the slight feeling that all those answers here seduce you to give up
> troubleshooting yourself ... I bet you could have figured this out too.

you probably noticed that i prefer to have as short as possible and as
default as possible gar-makefiles, and fix things upstream. the reason
is very simple: any line we write is work, and needs to be ported, and
supported.

and you are completely right: if i am not able to fix it in 10 minutes
i leave it. opencsw is nice, but it is in my free time and there might
be other priorities in somebodies life than hunting down some stupid
shell anachronism introduced in the computer science stone age. but
your statement really provoked me to look it up :)

and the result was that the problem boils down to "find the absolute
path of a script",
http://dbaspot.com/forums/shell/379501-finding-absolute-path-script-within.html,
 saying:
* "sh", pwd, dirname $0 can all be tricked into giving
   a wrong result. which then needs a workaround like
   your proposal.
* bash gives the desired result with
  script_path=${0%/*}

but finding the absolute path is only necessary as test.sh itself is
ugly and changes directories inside itself.

rupert.


More information about the maintainers mailing list