Permalink
Please sign in to comment.
Browse files
Implement the 'type' builtin (just the '-t' case), with tests.
Used by setup.sh in Nix. Addresses issue #26.
- Loading branch information...
Showing
with
115 additions
and 2 deletions.
- +59 −1 core/builtin.py
- +4 −0 core/cmd_exec.py
- +19 −1 osh/lex.py
- +27 −0 spec/builtin-type.test.sh
- +6 −0 test/spec.sh
| @@ -0,0 +1,27 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Bash implements type -t. | ||
| # | ||
| # NOTE: Aliases don't work in batch mode! Interactive only. | ||
| ### type -t builtin -> function | ||
| f() { echo hi; } | ||
| type -t f | ||
| # stdout-json: "function\n" | ||
| ### type -t builtin -> builtin | ||
| type -t echo read : [ declare local break continue | ||
| # stdout-json: "builtin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\nbuiltin\n" | ||
| ### type -t builtin -> keyword | ||
| type -t for time ! fi do { | ||
| # stdout-json: "keyword\nkeyword\nkeyword\nkeyword\nkeyword\nkeyword\n" | ||
| ### type -t builtin -> file | ||
| type -t find xargs | ||
| # stdout-json: "file\nfile\n" | ||
| ### type -t builtin -> not found | ||
| type -t echo ZZZ find = | ||
| echo status=$? | ||
| # stdout-json: "builtin\nfile\nstatus=1\n" |
0 comments on commit
5aaffbc