| 1 |
## oils_failures_allowed: 0
|
| 2 |
## compare_shells: bash
|
| 3 |
## legacy_tmp_dir: yes
|
| 4 |
|
| 5 |
|
| 6 |
f() { echo hi; }
|
| 7 |
type -t f
|
| 8 |
## stdout: function
|
| 9 |
|
| 10 |
|
| 11 |
shopt -s expand_aliases
|
| 12 |
alias foo=bar
|
| 13 |
type -t foo
|
| 14 |
## stdout: alias
|
| 15 |
|
| 16 |
|
| 17 |
type -t echo read : [ declare local
|
| 18 |
## STDOUT:
|
| 19 |
builtin
|
| 20 |
builtin
|
| 21 |
builtin
|
| 22 |
builtin
|
| 23 |
builtin
|
| 24 |
builtin
|
| 25 |
## END
|
| 26 |
|
| 27 |
|
| 28 |
type -t for time ! fi do {
|
| 29 |
## STDOUT:
|
| 30 |
keyword
|
| 31 |
keyword
|
| 32 |
keyword
|
| 33 |
keyword
|
| 34 |
keyword
|
| 35 |
keyword
|
| 36 |
## END
|
| 37 |
|
| 38 |
|
| 39 |
type -t break continue return exit
|
| 40 |
|
| 41 |
## STDOUT:
|
| 42 |
builtin
|
| 43 |
builtin
|
| 44 |
builtin
|
| 45 |
builtin
|
| 46 |
## END
|
| 47 |
|
| 48 |
# In OSH, tye are now keywords AND dynamic builtins
|
| 49 |
#
|
| 50 |
# We MAY make them builtins in OSH, and keywords in YSH
|
| 51 |
|
| 52 |
## OK osh STDOUT:
|
| 53 |
keyword
|
| 54 |
keyword
|
| 55 |
keyword
|
| 56 |
keyword
|
| 57 |
## END
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
type -t find xargs
|
| 62 |
## STDOUT:
|
| 63 |
file
|
| 64 |
file
|
| 65 |
## END
|
| 66 |
|
| 67 |
|
| 68 |
PATH="$TMP:$PATH"
|
| 69 |
touch $TMP/non-executable
|
| 70 |
type -t non-executable
|
| 71 |
## STDOUT:
|
| 72 |
## END
|
| 73 |
## status: 1
|
| 74 |
## BUG bash STDOUT:
|
| 75 |
file
|
| 76 |
## END
|
| 77 |
## BUG bash status: 0
|
| 78 |
|
| 79 |
|
| 80 |
type -t echo ZZZ find ==
|
| 81 |
echo status=$?
|
| 82 |
## STDOUT:
|
| 83 |
builtin
|
| 84 |
file
|
| 85 |
status=1
|
| 86 |
## END
|
| 87 |
## STDERR:
|
| 88 |
## END
|
| 89 |
|
| 90 |
|
| 91 |
touch /tmp/{mv,tar,grep}
|
| 92 |
chmod +x /tmp/{mv,tar,grep}
|
| 93 |
PATH=/tmp:$PATH
|
| 94 |
|
| 95 |
type -p mv tar grep
|
| 96 |
echo --
|
| 97 |
type -P mv tar grep
|
| 98 |
## STDOUT:
|
| 99 |
/tmp/mv
|
| 100 |
/tmp/tar
|
| 101 |
/tmp/grep
|
| 102 |
--
|
| 103 |
/tmp/mv
|
| 104 |
/tmp/tar
|
| 105 |
/tmp/grep
|
| 106 |
## END
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
touch _tmp/pwd
|
| 111 |
chmod +x _tmp/pwd
|
| 112 |
PATH="_tmp:/bin"
|
| 113 |
|
| 114 |
type -a -P pwd
|
| 115 |
|
| 116 |
## STDOUT:
|
| 117 |
_tmp/pwd
|
| 118 |
/bin/pwd
|
| 119 |
## END
|
| 120 |
|
| 121 |
|
| 122 |
type -p FOO BAR NOT_FOUND
|
| 123 |
## status: 1
|
| 124 |
## STDOUT:
|
| 125 |
## END
|
| 126 |
|
| 127 |
|
| 128 |
type -p cd type builtin command
|
| 129 |
## STDOUT:
|
| 130 |
## END
|
| 131 |
|
| 132 |
|
| 133 |
type -P FOO BAR NOT_FOUND
|
| 134 |
## status: 1
|
| 135 |
## STDOUT:
|
| 136 |
## END
|
| 137 |
|
| 138 |
|
| 139 |
type -P cd type builtin command
|
| 140 |
## status: 1
|
| 141 |
## STDOUT:
|
| 142 |
## END
|
| 143 |
|
| 144 |
|
| 145 |
touch _tmp/{mv,tar,grep}
|
| 146 |
chmod +x _tmp/{mv,tar,grep}
|
| 147 |
PATH=_tmp:$PATH
|
| 148 |
|
| 149 |
mv () { ls; }
|
| 150 |
tar () { ls; }
|
| 151 |
grep () { ls; }
|
| 152 |
type -P mv tar grep cd builtin command type
|
| 153 |
## status: 1
|
| 154 |
## STDOUT:
|
| 155 |
_tmp/mv
|
| 156 |
_tmp/tar
|
| 157 |
_tmp/grep
|
| 158 |
## END
|
| 159 |
|
| 160 |
|
| 161 |
type -f FOO BAR NOT FOUND
|
| 162 |
## status: 1
|
| 163 |
|
| 164 |
|
| 165 |
touch /tmp/{mv,tar,grep}
|
| 166 |
chmod +x /tmp/{mv,tar,grep}
|
| 167 |
PATH=/tmp:$PATH
|
| 168 |
|
| 169 |
mv () { ls; }
|
| 170 |
tar () { ls; }
|
| 171 |
grep () { ls; }
|
| 172 |
type -f mv tar grep
|
| 173 |
## STDOUT:
|
| 174 |
mv is /tmp/mv
|
| 175 |
tar is /tmp/tar
|
| 176 |
grep is /tmp/grep
|
| 177 |
## END
|
| 178 |
|
| 179 |
|
| 180 |
f () { echo; }
|
| 181 |
type -a f
|
| 182 |
echo
|
| 183 |
|
| 184 |
type f
|
| 185 |
|
| 186 |
## STDOUT:
|
| 187 |
f is a function
|
| 188 |
f ()
|
| 189 |
{
|
| 190 |
echo
|
| 191 |
}
|
| 192 |
|
| 193 |
f is a function
|
| 194 |
f ()
|
| 195 |
{
|
| 196 |
echo
|
| 197 |
}
|
| 198 |
## END
|
| 199 |
## OK osh STDOUT:
|
| 200 |
f is a shell function
|
| 201 |
f () { echo; }
|
| 202 |
|
| 203 |
f is a shell function
|
| 204 |
f () { echo; }
|
| 205 |
## END
|
| 206 |
|
| 207 |
|
| 208 |
f () { :; }
|
| 209 |
type -ap f
|
| 210 |
## STDOUT:
|
| 211 |
## END
|
| 212 |
|
| 213 |
|
| 214 |
shopt -s expand_aliases
|
| 215 |
alias ll="ls -lha"
|
| 216 |
type -a ll
|
| 217 |
## stdout: ll is an alias for "ls -lha"
|
| 218 |
## OK bash stdout: ll is aliased to `ls -lha'
|
| 219 |
|
| 220 |
|
| 221 |
shopt -s expand_aliases
|
| 222 |
alias ll="ls -lha"
|
| 223 |
type -ap ll
|
| 224 |
## STDOUT:
|
| 225 |
## END
|
| 226 |
|
| 227 |
|
| 228 |
type -a cd
|
| 229 |
## stdout: cd is a shell builtin
|
| 230 |
|
| 231 |
|
| 232 |
type -ap cd
|
| 233 |
## STDOUT:
|
| 234 |
## END
|
| 235 |
|
| 236 |
|
| 237 |
type -a while
|
| 238 |
## stdout: while is a shell keyword
|
| 239 |
|
| 240 |
|
| 241 |
touch _tmp/date
|
| 242 |
chmod +x _tmp/date
|
| 243 |
PATH=/bin:_tmp # control output
|
| 244 |
|
| 245 |
type -a date
|
| 246 |
|
| 247 |
## STDOUT:
|
| 248 |
date is /bin/date
|
| 249 |
date is _tmp/date
|
| 250 |
## END
|
| 251 |
|
| 252 |
|
| 253 |
touch _tmp/date
|
| 254 |
chmod +x _tmp/date
|
| 255 |
PATH=/bin:_tmp # control output
|
| 256 |
|
| 257 |
type -ap date
|
| 258 |
## STDOUT:
|
| 259 |
/bin/date
|
| 260 |
_tmp/date
|
| 261 |
## END
|
| 262 |
|
| 263 |
|
| 264 |
touch _tmp/pwd
|
| 265 |
chmod +x _tmp/pwd
|
| 266 |
PATH=/bin:_tmp # control output
|
| 267 |
|
| 268 |
type -a pwd
|
| 269 |
## STDOUT:
|
| 270 |
pwd is a shell builtin
|
| 271 |
pwd is /bin/pwd
|
| 272 |
pwd is _tmp/pwd
|
| 273 |
## END
|
| 274 |
|
| 275 |
|
| 276 |
touch _tmp/pwd
|
| 277 |
chmod +x _tmp/pwd
|
| 278 |
PATH=/bin:_tmp # control output
|
| 279 |
|
| 280 |
type -a pwd
|
| 281 |
echo ---
|
| 282 |
|
| 283 |
pwd ()
|
| 284 |
{
|
| 285 |
echo function-too
|
| 286 |
}
|
| 287 |
|
| 288 |
osh-normalize() {
|
| 289 |
sed 's/shell function/function/'
|
| 290 |
}
|
| 291 |
|
| 292 |
type -a pwd | osh-normalize
|
| 293 |
echo ---
|
| 294 |
|
| 295 |
type -a -f pwd | osh-normalize
|
| 296 |
|
| 297 |
## STDOUT:
|
| 298 |
pwd is a shell builtin
|
| 299 |
pwd is /bin/pwd
|
| 300 |
pwd is _tmp/pwd
|
| 301 |
---
|
| 302 |
pwd is a function
|
| 303 |
pwd ()
|
| 304 |
{
|
| 305 |
echo function-too
|
| 306 |
}
|
| 307 |
pwd is a shell builtin
|
| 308 |
pwd is /bin/pwd
|
| 309 |
pwd is _tmp/pwd
|
| 310 |
---
|
| 311 |
pwd is a shell builtin
|
| 312 |
pwd is /bin/pwd
|
| 313 |
pwd is _tmp/pwd
|
| 314 |
## END
|
| 315 |
|
| 316 |
|
| 317 |
touch _tmp/pwd
|
| 318 |
chmod +x _tmp/pwd
|
| 319 |
PATH=/bin:_tmp # control output
|
| 320 |
|
| 321 |
# Function is also ignored
|
| 322 |
pwd() { echo function-too; }
|
| 323 |
|
| 324 |
type -ap pwd
|
| 325 |
echo ---
|
| 326 |
|
| 327 |
type -p pwd
|
| 328 |
|
| 329 |
## STDOUT:
|
| 330 |
/bin/pwd
|
| 331 |
_tmp/pwd
|
| 332 |
---
|
| 333 |
## END
|
| 334 |
|
| 335 |
|
| 336 |
touch _tmp/executable
|
| 337 |
chmod +x _tmp/executable
|
| 338 |
type -a executable
|
| 339 |
## status: 1
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
mkdir -p _tmp
|
| 344 |
PATH="_tmp:$PATH"
|
| 345 |
mkdir _tmp/cat
|
| 346 |
|
| 347 |
type -P _tmp/cat
|
| 348 |
echo status=$?
|
| 349 |
type -P cat
|
| 350 |
echo status=$?
|
| 351 |
|
| 352 |
## STDOUT:
|
| 353 |
status=1
|
| 354 |
/usr/bin/cat
|
| 355 |
status=0
|
| 356 |
## END
|
| 357 |
|
| 358 |
## BUG mksh STDOUT:
|
| 359 |
status=1
|
| 360 |
cat
|
| 361 |
status=0
|
| 362 |
## END
|
| 363 |
|
| 364 |
## BUG ash/dash STDOUT:
|
| 365 |
_tmp/cat
|
| 366 |
status=0
|
| 367 |
/usr/bin/cat
|
| 368 |
status=0
|
| 369 |
## END
|