| 1 | ---
|
| 2 | default_highlighter: oils-sh
|
| 3 | ---
|
| 4 |
|
| 5 | Oils Error Catalog, With Hints
|
| 6 | ==================
|
| 7 |
|
| 8 | This doc lists errors from Oils (both [OSH]($xref) and [YSH]($xref)), with
|
| 9 | hints to help you fix them.
|
| 10 |
|
| 11 | Each error is associated with a code like `OILS-ERR-42`, a string that search
|
| 12 | engines should find.
|
| 13 |
|
| 14 | <!--
|
| 15 | Later, we could have a URL shortener, like https://oils.err/42
|
| 16 | -->
|
| 17 |
|
| 18 | <div id="toc">
|
| 19 | </div>
|
| 20 |
|
| 21 | ## How to Contribute
|
| 22 |
|
| 23 | If you see an error that you don't understand:
|
| 24 |
|
| 25 | 1. Ask a question on `#oil-help` on [Zulip]($xref:zulip). What's the problem,
|
| 26 | and what's the solution?
|
| 27 | 1. Then `grep` the source code for the confusing error message. Tag it with a
|
| 28 | string like `OILS-ERR-43`, picking a new number according to the conventions
|
| 29 | below.
|
| 30 | 1. Add a tagged section below, with hints and explanations.
|
| 31 | - Quote the error message. You may want copy and paste from the output of
|
| 32 | `test/{parse,runtime,ysh-parse,ysh-runtime}-errors.sh`. Add an HTML
|
| 33 | comment `<!-- -->` about that.
|
| 34 | - Link to relevant sections in the [**Oils Reference**](ref/index.html).
|
| 35 | 1. Optionally, add your name to the acknowledgements list at the end of this
|
| 36 | doc.
|
| 37 |
|
| 38 | Note that error messages are **hard** to write, because a single error could
|
| 39 | result from many different user **intentions**!
|
| 40 |
|
| 41 | ### To Preview this Doc
|
| 42 |
|
| 43 | Right now I use this command:
|
| 44 |
|
| 45 | build/doc.sh split-and-render doc/error-catalog.md
|
| 46 |
|
| 47 | Then paste this into your browser:
|
| 48 |
|
| 49 | file:///home/andy/git/oilshell/oil/_release/VERSION/doc/error-catalog.html
|
| 50 |
|
| 51 | (Replace with your home dir)
|
| 52 |
|
| 53 | ## Parse Errors - Rejected Input
|
| 54 |
|
| 55 | Roughly speaking, a parse error means that text input was **rejected**, so the
|
| 56 | shell didn't try to do anything.
|
| 57 |
|
| 58 | Examples:
|
| 59 |
|
| 60 | echo ) # Shell syntax error
|
| 61 |
|
| 62 | type -z # -z flag not accepted
|
| 63 |
|
| 64 | These error codes start at `10`.
|
| 65 |
|
| 66 | ### OILS-ERR-10
|
| 67 |
|
| 68 | <!--
|
| 69 | Generated with:
|
| 70 | test/ysh-parse-errors.sh test-func-var-checker
|
| 71 | -->
|
| 72 |
|
| 73 | ```
|
| 74 | setvar x = true
|
| 75 | ^
|
| 76 | [ -c flag ]:3: setvar couldn't find matching 'var x' (OILS-ERR-10)
|
| 77 | ```
|
| 78 |
|
| 79 | - Did you forget to declare the name with the [var](ref/chap-cmd-lang.html#var)
|
| 80 | keyword?
|
| 81 | - Did you mean to use the [setglobal](ref/chap-cmd-lang.html#setglobal)
|
| 82 | keyword?
|
| 83 |
|
| 84 | Related help topics:
|
| 85 |
|
| 86 | - [setvar](ref/chap-cmd-lang.html#setvar)
|
| 87 |
|
| 88 | ### OILS-ERR-11
|
| 89 |
|
| 90 | <!--
|
| 91 | Generated with:
|
| 92 | test/ysh-parse-errors.sh ysh_c_strings (this may move)
|
| 93 | -->
|
| 94 |
|
| 95 | ```
|
| 96 | echo $'\z'
|
| 97 | ^
|
| 98 | [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11)
|
| 99 | ```
|
| 100 |
|
| 101 | - Did you mean `$'\\z'`? Backslashes must be escaped in `$''` and `u''` and
|
| 102 | `b''` strings.
|
| 103 | - Did you mean something like `$'\n'`? Only valid escapes are accepted in YSH.
|
| 104 |
|
| 105 | Related help topics:
|
| 106 |
|
| 107 | - [osh-string](ref/chap-word-lang.html#osh-string) (word language)
|
| 108 | - [ysh-string](ref/chap-expr-lang.html#ysh-string) (expression language)
|
| 109 |
|
| 110 | ### OILS-ERR-12
|
| 111 |
|
| 112 | <!--
|
| 113 | Generated with:
|
| 114 | test/ysh-parse-errors.sh ysh_dq_strings (this may move)
|
| 115 | -->
|
| 116 |
|
| 117 | ```
|
| 118 | echo "\z"
|
| 119 | ^
|
| 120 | [ -c flag ]:1: Invalid char escape in double quoted string (OILS-ERR-12)
|
| 121 | ```
|
| 122 |
|
| 123 | - Did you mean `"\\z"`? Backslashes must be escaped in double-quoted strings.
|
| 124 | - Did you mean something like `"\$"`? Only valid escapes are accepted in YSH.
|
| 125 |
|
| 126 | Related help topics:
|
| 127 |
|
| 128 | - [osh-string](ref/chap-word-lang.html#osh-string) (word language)
|
| 129 | - [ysh-string](ref/chap-expr-lang.html#ysh-string) (expression language)
|
| 130 |
|
| 131 | ### OILS-ERR-13
|
| 132 |
|
| 133 | <!--
|
| 134 | Generated with:
|
| 135 | test/ysh-parse-errors.sh ysh_bare_words (this may move)
|
| 136 | -->
|
| 137 |
|
| 138 | ```
|
| 139 | echo \z
|
| 140 | ^~
|
| 141 | [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13)
|
| 142 | ```
|
| 143 |
|
| 144 | - Did you mean `\\z`? Backslashes must be escaped in unquoted words.
|
| 145 | - Did you mean something like `\$`? Only valid escapes are accepted in YSH.
|
| 146 |
|
| 147 | ## Runtime Errors - Traditional Shell
|
| 148 |
|
| 149 | These errors may occur in shells like [bash]($xref) and [zsh]($xref).
|
| 150 |
|
| 151 | They're numbered starting from `100`. (If we have more than 90 parse errors,
|
| 152 | we can start a new section, like `300`.)
|
| 153 |
|
| 154 | ### OILS-ERR-100
|
| 155 |
|
| 156 | Example TODO: Command not found.
|
| 157 |
|
| 158 | - Is the file in your `$PATH`? That variable controls where the shell shell
|
| 159 | looks for executable files.
|
| 160 | - Did you misspell a shell function or YSH `proc`?
|
| 161 |
|
| 162 | ## Runtime Errors - Oils and YSH
|
| 163 |
|
| 164 | These errors don't occur in shells like [bash]($xref) and [zsh]($xref).
|
| 165 |
|
| 166 | They may involve Python-like **expressions** and **typed data**.
|
| 167 |
|
| 168 | They're numbered starting from `200`.
|
| 169 |
|
| 170 | ### OILS-ERR-200
|
| 171 |
|
| 172 | <!--
|
| 173 | Generated with:
|
| 174 | test/runtime-errors.sh test-external_cmd_typed_args
|
| 175 | -->
|
| 176 |
|
| 177 | ```
|
| 178 | cat ("myfile")
|
| 179 | ^
|
| 180 | [ -c flag ]:1: fatal: 'cat' appears to be external. External commands don't accept typed args (OILS-ERR-200)
|
| 181 | ```
|
| 182 |
|
| 183 | - Builtin commands and user-defined procs may accept [typed
|
| 184 | args](ref/chap-cmd-lang.html#typed-arg), but external commands never do.
|
| 185 | - Did you misspell a [YSH proc](ref/chap-cmd-lang.html#proc-def)? If a name is
|
| 186 | not found, YSH assumes it's an external command.
|
| 187 | - Did you forget to source a file that contains the proc or shell function you
|
| 188 | wanted to run?
|
| 189 |
|
| 190 | ## Appendix
|
| 191 |
|
| 192 | ### Kinds of Errors from Oils
|
| 193 |
|
| 194 | - Runtime errors (status 1) - the shell tried to do something, but failed.
|
| 195 | - Example: `echo hi > /does/not/exist`
|
| 196 | - Parse errors and builtin usage errors (status 2) - input rejected, so the
|
| 197 | shell didn't try to do anything.
|
| 198 | - Uncaught I/O errors (status 2)
|
| 199 | - Expression errors (status 3)
|
| 200 | - User errors from the `error` builtin (status 10 is default)
|
| 201 |
|
| 202 | ### Contributors
|
| 203 |
|
| 204 | (If you updated this doc, feel free to add your name to the end of this list.)
|
| 205 |
|