Skip to content

Commit

Permalink
As in the unquoted case, we now now parse it and reject it at runtime.
Browse files Browse the repository at this point in the history
This is issue #2234.
  • Loading branch information
Andy C committed Jan 21, 2025
1 parent f011d93 commit 4986f63
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions doc/htm8.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ This makes lexing the top-level structure easier.

- HTM8 tags must be balanced to convert them to XML

- `<script></SCRIPT>` isn't matched
- the begin and end tags must match exactly, like `<SCRipt></SCRipt>`
- likewise for `<style>`

- NUL bytes aren't allowed - currently due to re2c sentinel. Two options:
1. Make it a syntax error - like JSON8
1. we could have a reprocessing pass to convert it to the Unicode replacement
Expand Down
3 changes: 3 additions & 0 deletions osh/word_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,9 @@ def _ReadDoubleQuotedLeftParts(self):
if self.token_type == Id.Left_DollarBracket:
return self._ReadExprSub(lex_mode_e.DQ)

if self.token_type == Id.Left_DollarBraceZsh:
return self._ReadZshVarSub(self.cur_token)

raise AssertionError(self.cur_token)

def _ReadYshSingleQuoted(self, left_id):
Expand Down
22 changes: 17 additions & 5 deletions spec/zsh-idioms.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,32 @@ fi

#### zsh var sub is rejected at runtime

echo z ${(m)foo} z
eval 'echo z ${(m)foo} z'
echo status=$?

eval 'echo ${x:-${(m)foo}}'
echo status=$?

# double quoted
eval 'echo "${(m)foo}"'
echo status=$?

## status: 1
## STDOUT:
status=1
status=1
status=1
## END

## OK zsh status: 0
## OK zsh STDOUT:
z z
status=0

status=0

status=0
## END

## OK bash status: 0
## OK bash STDOUT:
status=1
## BUG mksh status: 1
## BUG mksh STDOUT:
## END

0 comments on commit 4986f63

Please sign in to comment.