| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Bash implements type -t. |
| 4 | # |
| 5 | # NOTE: Aliases don't work in batch mode! Interactive only. |
| 6 | |
| 7 | ### type -t builtin -> function |
| 8 | f() { echo hi; } |
| 9 | type -t f |
| 10 | # stdout-json: "function\n" |
| 11 | |
| 12 | ### type -t builtin -> builtin |
| 13 | type -t echo read : [ declare local break continue |
| 14 | # stdout-json: "builtin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\n" |
| 15 | |
| 16 | ### type -t builtin -> keyword |
| 17 | type -t for time ! fi do { |
| 18 | # stdout-json: "keyword\nkeyword\nkeyword\nkeyword\nkeyword\nkeyword\n" |
| 19 | |
| 20 | ### type -t builtin -> file |
| 21 | type -t find xargs |
| 22 | # stdout-json: "file\nfile\n" |
| 23 | |
| 24 | ### type -t builtin -> not found |
| 25 | type -t echo ZZZ find = |
| 26 | echo status=$? |
| 27 | # stdout-json: "builtin\nfile\nstatus=1\n" |