Re: Making a path absolute portably

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 10 Jul 2019, Sébastien Hinderer wrote:

Dear all,

I'd need to compute the absolute path of srcdir in a portable way (it's
okay if it includes symlinks).

Currently I use

abssrcdir=$(cd "${srcdir}"; echo $PWD)
which seems to work fine.

Is that considered portable enough?

It appears that $PWD is a shell extension, so I don't think so. Even the shell syntax being used to execute the external command is not very portable. In addition to that, if the cd "${srcdir}" fails, it would then capture the wrong directory.

This syntax is proven to be portable and reliable:

abssrcdir="`cd $srcdir && pwd`"

Bob
--
Bob Friesenhahn
bfriesen@xxxxxxxxxxxxxxxxxxx, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux