You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Jan Lehnardt <ja...@apache.org> on 2015/04/03 15:38:22 UTC

./configure question

Hey all / Paul,

can anyone unpack this line from our ./configure script for me?

  rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"

As far as I can tell, this results in $PWD being assigned to rootdir, what is the other magic? :)

Thanks!
Jan
-- 







Re: ./configure question

Posted by Jan Lehnardt <ja...@apache.org>.
Excellent, thanks!

> On 03 Apr 2015, at 16:11, Alexander Shorin <kx...@gmail.com> wrote:
> 
> On Fri, Apr 3, 2015 at 5:02 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>> On 03 Apr 2015, at 15:55, Alexander Shorin <kx...@gmail.com> wrote:
>>> 
>>> On Fri, Apr 3, 2015 at 4:46 PM, Alexander Shorin <kx...@gmail.com> wrote:
>>>> On Fri, Apr 3, 2015 at 4:38 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>> rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
>>>> 
>>>> ${0} - executable path. like shell
>>>> ${0%/*} - get parent directory of this path
>>>> $(cd ${0%/*}) - execute a shell command
>>>> since cd changes current directory, it also updates environment
>>>> variable $PWD according it. In case of success you'll be moved to
>>>> somewhere like /bin (for me)
>>> 
>>> TL;DR that script is to find full path of an executed script and
>>> ensure that location is accessible and set rootdir with the directory
>>> path where those configure script is located.
>> 
>> Thanks!
>> 
>> I assume this is for cases where people do /path/to/couchdb/configure, right?
> 
> Yes, or if the path is relative - any case will give correct root
> directory for the other relative paths.
> 
> --
> ,,,^..^,,,

-- 
Professional Support for Apache CouchDB:
http://www.neighbourhood.ie/couchdb-support/


Re: ./configure question

Posted by Alexander Shorin <kx...@gmail.com>.
On Fri, Apr 3, 2015 at 5:02 PM, Jan Lehnardt <ja...@apache.org> wrote:
>> On 03 Apr 2015, at 15:55, Alexander Shorin <kx...@gmail.com> wrote:
>>
>> On Fri, Apr 3, 2015 at 4:46 PM, Alexander Shorin <kx...@gmail.com> wrote:
>>> On Fri, Apr 3, 2015 at 4:38 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>>> rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
>>>
>>> ${0} - executable path. like shell
>>> ${0%/*} - get parent directory of this path
>>> $(cd ${0%/*}) - execute a shell command
>>> since cd changes current directory, it also updates environment
>>> variable $PWD according it. In case of success you'll be moved to
>>> somewhere like /bin (for me)
>>
>> TL;DR that script is to find full path of an executed script and
>> ensure that location is accessible and set rootdir with the directory
>> path where those configure script is located.
>
> Thanks!
>
> I assume this is for cases where people do /path/to/couchdb/configure, right?

Yes, or if the path is relative - any case will give correct root
directory for the other relative paths.

--
,,,^..^,,,

Re: ./configure question

Posted by Jan Lehnardt <ja...@apache.org>.
> On 03 Apr 2015, at 15:55, Alexander Shorin <kx...@gmail.com> wrote:
> 
> On Fri, Apr 3, 2015 at 4:46 PM, Alexander Shorin <kx...@gmail.com> wrote:
>> On Fri, Apr 3, 2015 at 4:38 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>> rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
>> 
>> ${0} - executable path. like shell
>> ${0%/*} - get parent directory of this path
>> $(cd ${0%/*}) - execute a shell command
>> since cd changes current directory, it also updates environment
>> variable $PWD according it. In case of success you'll be moved to
>> somewhere like /bin (for me)
> 
> TL;DR that script is to find full path of an executed script and
> ensure that location is accessible and set rootdir with the directory
> path where those configure script is located.

Thanks!

I assume this is for cases where people do /path/to/couchdb/configure, right?

Best
Jan
--


Re: ./configure question

Posted by Alexander Shorin <kx...@gmail.com>.
On Fri, Apr 3, 2015 at 4:46 PM, Alexander Shorin <kx...@gmail.com> wrote:
> On Fri, Apr 3, 2015 at 4:38 PM, Jan Lehnardt <ja...@apache.org> wrote:
>> rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
>
> ${0} - executable path. like shell
> ${0%/*} - get parent directory of this path
> $(cd ${0%/*}) - execute a shell command
> since cd changes current directory, it also updates environment
> variable $PWD according it. In case of success you'll be moved to
> somewhere like /bin (for me)

TL;DR that script is to find full path of an executed script and
ensure that location is accessible and set rootdir with the directory
path where those configure script is located.

--
,,,^..^,,,

Re: ./configure question

Posted by Alexander Shorin <kx...@gmail.com>.
On Fri, Apr 3, 2015 at 4:38 PM, Jan Lehnardt <ja...@apache.org> wrote:
> rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"

${0} - executable path. like shell
${0%/*} - get parent directory of this path
$(cd ${0%/*}) - execute a shell command
since cd changes current directory, it also updates environment
variable $PWD according it. In case of success you'll be moved to
somewhere like /bin (for me)

--
,,,^..^,,,