| 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" |
| 28 | |
| 29 | #### help |
| 30 | help |
| 31 | help help |
| 32 | ## status: 0 |
| 33 | |
| 34 | #### bad help topic |
| 35 | help ZZZ 2>$TMP/err.txt |
| 36 | echo "help=$?" |
| 37 | cat $TMP/err.txt | grep -i 'no help topics' >/dev/null |
| 38 | echo "grep=$?" |
| 39 | ## stdout-json: "help=1\ngrep=0\n" |