builtin-test.sh 683 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. source $(dirname "$0")/test-commons.inc
  3. if not [ "$(type ls)" = "ls is $(which ls)" ] { fail "'type' on a binary not working" }
  4. if not [ "$(type pwd)" = "pwd is a shell builtin" ] { fail "'type' on a builtin not working" }
  5. f() { ls }
  6. if not [ "$(type f)" = "f is a function f() { ls }" ] { fail "'type' on a function not working" }
  7. if not [ "$(type -f f)" = "f is a function" ] { fail "'type' on a function not working with -f" }
  8. alias l=ls
  9. if not [ "$(type l)" = "l is aliased to `ls`" ] { fail "'type' on a alias not working" }
  10. if not [ "$(type l ls)" = "l is aliased to `ls` ls is $(which ls)" ] { fail "'type' on multiple commands not working" }
  11. echo PASS