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
bfrie...@simple.dallas.tx.us, 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@gnu.org
https://lists.gnu.org/mailman/listinfo/autoconf

Reply via email to