1 # $FreeBSD: head/bin/sh/tests/builtins/cd4.0 222154 2011-05-20 22:55:18Z jilles $
 
   3 # This test assumes that whatever mechanism cd -P uses to determine the
 
   4 # pathname to the current directory if it is longer than PATH_MAX requires
 
   5 # read permission on all parent directories. It also works if this
 
   6 # requirement always applies.
 
   9 L=$(getconf PATH_MAX / 2>/dev/null) || L=4096
 
  10 [ "$L" -lt 100000 ] 2>/dev/null || L=4096
 
  12 T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
 
  13 trap 'chmod u+r ${T}; rm -rf ${T}' 0
 
  18         # Running as root, cannot test.
 
  22 while [ ${#D} -lt $L ]; do
 
  23         mkdir veryverylongdirectoryname || exit
 
  24         cd -Pe veryverylongdirectoryname 2>/dev/null
 
  26         [ $r -gt 1 ] && exit $r
 
  28                 # Verify that the directory was changed correctly.
 
  30                 [ "$(pwd)" = "$D" ] || exit
 
  31                 # Verify that omitting -e results in success.
 
  32                 cd -P veryverylongdirectoryname 2>/dev/null || exit
 
  35         D=$D/veryverylongdirectoryname
 
  37 echo "cd -Pe never returned 1"