minimal/do: use 'pwd -P' instead of '/bin/pwd'.

On MacOS (at least 10.11.6), /bin/pwd defaults to using $PWD (ie.  pwd
-L).  On most other OSes it defaults to *not* using $PWD (ie.  pwd -P).
We need the latter behaviour.  It appears that 'pwd -P' has been
specified by POSIX for quite a few years now, so let's rely on it.
shelltest.od will now also check for it, though if your 'sh' doesn't
support this feature, it'll be too late, because shelltest needs
minimal/do in order to run.
This commit is contained in:
Avery Pennarun 2019-01-01 19:10:55 -05:00
commit 613fcb1c34
2 changed files with 7 additions and 3 deletions

View file

@ -44,7 +44,7 @@ qdirname()
)
_dirsplit "$0"
REDO=$(cd "$(/bin/pwd)" &&
REDO=$(cd "$(pwd -P)" &&
cd "${_dirsplit_dir:-.}" &&
echo "$PWD/$_dirsplit_base")
export REDO
@ -79,7 +79,7 @@ if [ -z "$DO_BUILT" -a "$_cmd" != "redo-whichdo" ]; then
if [ "$#" -eq 0 ] && [ "$_cmd" = "do" -o "$_cmd" = "redo" ]; then
set all # only toplevel redo has a default target
fi
export DO_STARTDIR="$(/bin/pwd)"
export DO_STARTDIR="$(pwd -P)"
# If starting /bin/pwd != $PWD, this will fix it.
# That can happen when $PWD contains symlinks that the shell is
# trying helpfully (but unsuccessfully) to hide from the user.
@ -218,7 +218,7 @@ _realpath()
#echo "Trying: $PWD--$path" >&2
if cd -P "$path" 2>/dev/null; then
# success
pwd=$(/bin/pwd)
pwd=$(pwd -P)
#echo " chdir ok: $pwd--$rest" >&2
np=$(_normpath "${pwd%/}/$rest" "$relto")
if [ -n "$isabs" ]; then