1 |
# builtins specific to bash and OSH |
2 |
|
3 |
#### help |
4 |
help |
5 |
echo status=$? >&2 |
6 |
help help |
7 |
echo status=$? >&2 |
8 |
help -- help |
9 |
echo status=$? >&2 |
10 |
## STDERR: |
11 |
status=0 |
12 |
status=0 |
13 |
status=0 |
14 |
## END |
15 |
|
16 |
#### bad help topic |
17 |
help ZZZ 2>$TMP/err.txt |
18 |
echo "help=$?" |
19 |
cat $TMP/err.txt | grep -i 'no help topics' >/dev/null |
20 |
echo "grep=$?" |
21 |
## STDOUT: |
22 |
help=1 |
23 |
grep=0 |
24 |
## END |
25 |
|
26 |
#### type -t -> function |
27 |
f() { echo hi; } |
28 |
type -t f |
29 |
## stdout: function |
30 |
|
31 |
#### type -t -> alias |
32 |
shopt -s expand_aliases |
33 |
alias foo=bar |
34 |
type -t foo |
35 |
## stdout: alias |
36 |
|
37 |
#### type -t -> builtin |
38 |
type -t echo read : [ declare local |
39 |
## STDOUT: |
40 |
builtin |
41 |
builtin |
42 |
builtin |
43 |
builtin |
44 |
builtin |
45 |
builtin |
46 |
## END |
47 |
|
48 |
#### type -t -> keyword |
49 |
type -t for time ! fi do { |
50 |
## STDOUT: |
51 |
keyword |
52 |
keyword |
53 |
keyword |
54 |
keyword |
55 |
keyword |
56 |
keyword |
57 |
## END |
58 |
|
59 |
#### type -t control flow |
60 |
|
61 |
# this differs from bash, but don't lie! |
62 |
type -t break continue return exit |
63 |
## STDOUT: |
64 |
keyword |
65 |
keyword |
66 |
keyword |
67 |
keyword |
68 |
## END |
69 |
## OK bash STDOUT: |
70 |
builtin |
71 |
builtin |
72 |
builtin |
73 |
builtin |
74 |
## END |
75 |
|
76 |
|
77 |
#### type -t -> file |
78 |
type -t find xargs |
79 |
## STDOUT: |
80 |
file |
81 |
file |
82 |
## END |
83 |
|
84 |
#### type -t doesn't find non-executable (like command -v) |
85 |
PATH="$TMP:$PATH" |
86 |
touch $TMP/non-executable |
87 |
type -t non-executable |
88 |
## stdout-json: "" |
89 |
## status: 1 |
90 |
## BUG bash STDOUT: |
91 |
file |
92 |
## END |
93 |
## BUG bash status: 0 |
94 |
|
95 |
#### type -t -> not found |
96 |
type -t echo ZZZ find = |
97 |
echo status=$? |
98 |
## STDOUT: |
99 |
builtin |
100 |
file |
101 |
status=1 |
102 |
## END |
103 |
|
104 |
#### type -p builtin -> file |
105 |
type -p mv tar grep |
106 |
## STDOUT: |
107 |
/bin/mv |
108 |
/bin/tar |
109 |
/bin/grep |
110 |
## END |
111 |
|
112 |
#### type -p builtin -> not found |
113 |
type -p FOO BAR NOT_FOUND |
114 |
## status: 1 |
115 |
## stdout-json: "" |
116 |
|
117 |
#### type -p builtin -> not a file |
118 |
type -p cd type builtin command |
119 |
## stdout-json: "" |
120 |
|
121 |
#### type -P builtin -> file |
122 |
type -P mv tar grep |
123 |
## STDOUT: |
124 |
/bin/mv |
125 |
/bin/tar |
126 |
/bin/grep |
127 |
## END |
128 |
|
129 |
#### type -P builtin -> not found |
130 |
type -P FOO BAR NOT_FOUND |
131 |
## status: 1 |
132 |
## stdout-json: "" |
133 |
|
134 |
#### type -P builtin -> not a file |
135 |
type -P cd type builtin command |
136 |
## stdout-json: "" |
137 |
## status: 1 |
138 |
|
139 |
#### type -P builtin -> not a file but file found |
140 |
mv () { ls; } |
141 |
tar () { ls; } |
142 |
grep () { ls; } |
143 |
type -P mv tar grep cd builtin command type |
144 |
## status: 1 |
145 |
## STDOUT: |
146 |
/bin/mv |
147 |
/bin/tar |
148 |
/bin/grep |
149 |
## END |
150 |
|
151 |
#### type -f builtin -> not found |
152 |
type -f FOO BAR NOT FOUND |
153 |
## status: 1 |
154 |
|
155 |
#### type -f builtin -> function and file exists |
156 |
mv () { ls; } |
157 |
tar () { ls; } |
158 |
grep () { ls; } |
159 |
type -f mv tar grep |
160 |
## STDOUT: |
161 |
/bin/mv is a file |
162 |
/bin/tar is a file |
163 |
/bin/grep is a file |
164 |
## OK bash STDOUT: |
165 |
mv is /bin/mv |
166 |
tar is /bin/tar |
167 |
grep is /bin/grep |