1 ## oils_failures_allowed: 0
2 ## compare_shells: bash zsh mksh dash ash
3
4 #### type -> keyword builtin
5
6 type while cd
7
8 ## STDOUT:
9 while is a shell keyword
10 cd is a shell builtin
11 ## END
12 ## OK zsh/mksh STDOUT:
13 while is a reserved word
14 cd is a shell builtin
15 ## END
16
17 #### type -> alias function external
18
19 shopt -s expand_aliases || true # bash
20
21 alias ll='ls -l'
22
23 f() { echo hi; }
24
25 touch _tmp/date
26 chmod +x _tmp/date
27 PATH=_tmp:/bin
28
29 # ignore quotes and backticks
30 # bash prints a left backtick
31 quotes='"`'\'
32
33 type ll f date | sed "s/[$quotes]//g"
34
35 # Note: both procs and funcs go in var namespace? So they don't respond to
36 # 'type'?
37
38 ## STDOUT:
39 ll is an alias for ls -l
40 f is a shell function
41 date is _tmp/date
42 ## END
43 ## OK ash STDOUT:
44 ll is an alias for ls -l
45 f is a function
46 date is _tmp/date
47 ## END
48 ## OK mksh STDOUT:
49 ll is an alias for ls -l
50 f is a function
51 date is a tracked alias for _tmp/date
52 ## END
53 ## OK bash STDOUT:
54 ll is aliased to ls -l
55 f is a function
56 f ()
57 {
58 echo hi
59 }
60 date is _tmp/date
61 ## END
62
63 #### type of relative path
64
65 touch _tmp/file _tmp/ex
66 chmod +x _tmp/ex
67
68 type _tmp/file _tmp/ex
69
70 # dash and ash don't care if it's executable
71 # mksh
72
73 ## status: 1
74 ## STDOUT:
75 _tmp/ex is _tmp/ex
76 ## END
77
78 ## OK mksh/zsh STDOUT:
79 _tmp/file not found
80 _tmp/ex is _tmp/ex
81 ## END
82
83 ## BUG dash/ash status: 0
84 ## BUG dash/ash STDOUT:
85 _tmp/file is _tmp/file
86 _tmp/ex is _tmp/ex
87 ## END
88
89 #### type -> not found
90
91 type zz 2>err.txt
92 echo status=$?
93
94 # for bash and OSH: print to stderr
95 fgrep -o 'zz: not found' err.txt || true
96
97 # zsh and mksh behave the same - status 1
98 # dash and ash behave the same - status 127
99
100 ## STDOUT:
101 status=1
102 zz: not found
103 ## END
104
105 ## OK mksh/zsh STDOUT:
106 zz not found
107 status=1
108 ## END
109 ## STDERR:
110 ## END
111
112 ## BUG dash/ash STDOUT:
113 zz: not found
114 status=127
115 ## END
116 ## BUG dash/ash STDERR:
117 ## END