-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the 'type' builtin (just the '-t' case), with tests.
Used by setup.sh in Nix. Addresses issue #26.
- Loading branch information
Andy Chu
committed
Sep 6, 2017
1 parent
bbe5808
commit 5aaffbc
Showing
5 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters