Message ID | 87610xisjp.fsf@gnu.org |
---|---|
State | New |
Headers | show |
On Thu, 19 Nov 2015, Ludovic Courtès wrote: > AFAIK insisting on /bin/pwd is unnecessary nowadays. Autoconf-generated > scripts have been using the shell’s built-in ‘pwd’ for a long time. The point of at least some of these uses of pwd is to get the physical directory with symlinks resolved, not the shell's notion of the directory that may involve symlinks. It would need to be pwd -P, if that's sufficiently portable. (Really io/ftwtest-sh should be running pwd on the test host not the build system, but that would require a new addition to the set of test-wrapper makefile variables.)
Joseph Myers <joseph@codesourcery.com> skribis: > On Thu, 19 Nov 2015, Ludovic Courtès wrote: > >> AFAIK insisting on /bin/pwd is unnecessary nowadays. Autoconf-generated >> scripts have been using the shell’s built-in ‘pwd’ for a long time. > > The point of at least some of these uses of pwd is to get the physical > directory with symlinks resolved, not the shell's notion of the directory > that may involve symlinks. It would need to be pwd -P, if that's > sufficiently portable. It’s not clear to which of these uses want the canonical directory name. Which ones did you have in mind? AFAIK ‘pwd -P’ is sufficiently potable (definitely works with Bash and Dash.) Thanks, Ludo’.
On Fri, 20 Nov 2015, Ludovic Courtès wrote: > Joseph Myers <joseph@codesourcery.com> skribis: > > > On Thu, 19 Nov 2015, Ludovic Courtès wrote: > > > >> AFAIK insisting on /bin/pwd is unnecessary nowadays. Autoconf-generated > >> scripts have been using the shell’s built-in ‘pwd’ for a long time. > > > > The point of at least some of these uses of pwd is to get the physical > > directory with symlinks resolved, not the shell's notion of the directory > > that may involve symlinks. It would need to be pwd -P, if that's > > sufficiently portable. > > It’s not clear to which of these uses want the canonical directory > name. Which ones did you have in mind? I think all of those uses need the canonical name.
--- configure | 2 +- configure.ac | 2 +- io/ftwtest-sh | 8 ++++---- scripts/rellns-sh | 18 +++++------------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/configure b/configure index 90953f0..936b4b6 100755 --- a/configure +++ b/configure @@ -3228,7 +3228,7 @@ if test $libc_cv_cxx_link_ok != yes; then : CXX= fi -if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then +if test "`cd $srcdir; pwd`" = "`pwd`"; then as_fn_error $? "you must configure in a separate build directory" "$LINENO" 5 fi diff --git a/configure.ac b/configure.ac index cd37433..b8077a9 100644 --- a/configure.ac +++ b/configure.ac @@ -80,7 +80,7 @@ LDFLAGS="$old_LDFLAGS" AC_LANG_POP([C++])]) AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=]) -if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then +if test "`cd $srcdir; pwd`" = "`pwd`"; then AC_MSG_ERROR([you must configure in a separate build directory]) fi diff --git a/io/ftwtest-sh b/io/ftwtest-sh index 8669eab..ad23514 100644 --- a/io/ftwtest-sh +++ b/io/ftwtest-sh @@ -135,7 +135,7 @@ $testprogram --chdir $tmpdir | sort > $testout # perhaps $tmp involves some symlinks... -tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd` +tmpreal=`cd $tmp; pwd 2>/dev/null` cat <<EOF | cmp $testout - || exit 1 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0 @@ -153,7 +153,7 @@ base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd EOF rm $testout -curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd` +curwd=`pwd 2>/dev/null` cd "$tmp" $testprogram --chdir ftwtest.d | sort > $testout @@ -175,7 +175,7 @@ base = "ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tm EOF rm $testout -curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd` +curwd=`pwd` cd "$tmp" $testprogram --chdir ftwtest.d/. | sort > $testout @@ -197,7 +197,7 @@ base = "ftwtest.d/./foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $ EOF rm $testout -curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd` +curwd=`pwd 2>/dev/null` cd "$tmp" $testprogram --chdir ftwtest.d/foo/lvl1/link@1 | sort > $testout diff --git a/scripts/rellns-sh b/scripts/rellns-sh index f107433..ce694d1 100755 --- a/scripts/rellns-sh +++ b/scripts/rellns-sh @@ -30,23 +30,15 @@ if test $# -ne 2; then exit 1 fi -if test -x /bin/pwd; then - pwd=/bin/pwd -elif test -x /usr/bin/pwd; then - pwd=/usr/bin/pwd -else - pwd='pwd' -fi - # Make both paths absolute. if test -d $1; then - to=`cd $1 && $pwd` + to=`cd $1 && pwd` else temp=`echo $1 | sed 's%/*[^/]*$%%'` if test -z "$temp"; then - to=`$pwd` + to=`pwd` else - to=`cd $temp && $pwd` + to=`cd $temp && pwd` fi to="$to/`echo $1 | sed 's%.*/\([^/][^/]*\)$%\1%'`" fi @@ -59,9 +51,9 @@ else fi if test -z "$from"; then - from=`$pwd | sed 's%^/%%'` + from=`pwd | sed 's%^/%%'` else - from=`cd $from && $pwd | sed 's%^/%%'` + from=`cd $from && pwd | sed 's%^/%%'` fi while test -n "$to" && test -n "$from"; do -- 2.6.3