| 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
|
| 118 |
|
| 119 | #### special builtins are called out
|
| 120 | type cd
|
| 121 | type eval
|
| 122 | type :
|
| 123 | type true
|
| 124 |
|
| 125 | echo
|
| 126 | type export
|
| 127 |
|
| 128 | ## STDOUT:
|
| 129 | cd is a shell builtin
|
| 130 | eval is a special shell builtin
|
| 131 | : is a special shell builtin
|
| 132 | true is a shell builtin
|
| 133 |
|
| 134 | export is a special shell builtin
|
| 135 | ## END
|
| 136 |
|
| 137 | ## N-I bash STDOUT:
|
| 138 | cd is a shell builtin
|
| 139 | eval is a shell builtin
|
| 140 | : is a shell builtin
|
| 141 | true is a shell builtin
|
| 142 |
|
| 143 | export is a shell builtin
|
| 144 | ## END
|
| 145 |
|
| 146 | ## N-I zsh STDOUT:
|
| 147 | cd is a shell builtin
|
| 148 | eval is a shell builtin
|
| 149 | : is a shell builtin
|
| 150 | true is a shell builtin
|
| 151 |
|
| 152 | export is a reserved word
|
| 153 | ## END
|
| 154 |
|
| 155 | #### more special builtins
|
| 156 | case $SH in bash|zsh|dash) exit ;; esac
|
| 157 |
|
| 158 | type .
|
| 159 | type source
|
| 160 |
|
| 161 | # no agreement here!
|
| 162 | # type local
|
| 163 | # type typeset
|
| 164 |
|
| 165 | ## STDOUT:
|
| 166 | . is a special shell builtin
|
| 167 | source is a shell builtin
|
| 168 | ## END
|
| 169 |
|
| 170 | ## BUG ash STDOUT:
|
| 171 | . is a special shell builtin
|
| 172 | source is a special shell builtin
|
| 173 | ## END
|
| 174 |
|
| 175 | ## N-I bash/zsh/dash STDOUT:
|
| 176 | ## END
|