Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/error-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,22 @@ Try one of these alternatives:

ysh$ echo $['--flag=' ++ myvar] # expression sub


### OILS-ERR-18

```
echo "date = `date`"
^
[ -c flag ]:1: Backtick should be $(cmd) or \` (parse_backticks, OILS-ERR-18)
```

- Did you mean to use `$(date)` instead?
- This is the only syntax for command substitution in YSH, because it nests
cleanly.
- Did you mean to escape the backtick with `` \` ``?
- (OSH and YSH have the same string literal syntax, including the
backslash-quoted backtick `` \` ``.)

## Runtime Errors - Traditional Shell

These errors may occur in shells like [bash]($xref) and [zsh]($xref).
Expand Down
5 changes: 2 additions & 3 deletions osh/word_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts):

elif self.token_kind == Kind.Left:
if self.token_type == Id.Left_Backtick and is_ysh_expr:
p_die("Invalid backtick: use $(cmd) or \\` in YSH strings",
self.cur_token)
p_die("Backtick should be $(cmd) or \\` (OILS-ERR-18)", self.cur_token)

part = self._ReadDoubleQuotedLeftParts()
out_parts.append(part)
Expand Down Expand Up @@ -1210,7 +1209,7 @@ def _ReadCommandSub(self, left_id, d_quoted=False):

elif left_id == Id.Left_Backtick:
if not self.parse_opts.parse_backticks():
p_die('Use $(cmd) instead of backticks (parse_backticks)',
p_die('Backtick should be $(cmd) or \\` (parse_backticks, OILS-ERR-18)',
left_token)

self._SetNext(lex_mode_e.Backtick) # advance past `
Expand Down