hash-error.sh 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #! /bin/sh
  2. test -d foo1 || mkdir foo1
  3. test -d foo2 || mkdir foo2
  4. test -d foo2 || mkdir foo3
  5. echo 'echo :one' > foo1/run
  6. echo 'echo :two' > foo2/run
  7. echo 'echo :three' > foo2/run3
  8. chmod a+x */run*
  9. hash -r
  10. PATH=./foo3:./foo1:./foo2:./foo5
  11. echo Expect one:
  12. PATH=./foo3:./foo3:./foo1 run
  13. echo $PATH
  14. echo ERROR: run should be in in foo1, but is in two in old sh:
  15. hash -v
  16. echo ERROR: should give one, but does two in old sh:
  17. run
  18. hash -r
  19. echo
  20. echo Expect two:
  21. PATH=./foo3:./foo4:./foo3:./foo2:./foo5
  22. run
  23. hash -v
  24. echo ERROR: Expect one, does not find run on old sh:
  25. PATH=./foo3:./foo3:./foo1 run
  26. echo
  27. hash -r
  28. PATH=./foo3:./foo1:./foo4:./foo5
  29. echo Expect one, error preparation:
  30. PATH=./foo3:./foo4:./foo1 run
  31. echo Should show run in the wrong place:
  32. hash -v
  33. echo ERROR: Will not find run in old sh, should give one:
  34. run
  35. echo
  36. echo expect one
  37. PATH=./foo1:./foo2
  38. run
  39. echo expect three...
  40. PATH=./foo3:./foo4:./foo2 run3
  41. echo ERROR ... and now a coredump
  42. hash -v