Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash with double quoted zsh var in osh #2234

Open
lincheney opened this issue Jan 20, 2025 · 2 comments
Open

crash with double quoted zsh var in osh #2234

lincheney opened this issue Jan 20, 2025 · 2 comments

Comments

@lincheney
Copy link

Hi,

I accidentally ran some zsh inside osh (0.26.0) and it causes it to crash:

osh-0.26.0$ echo "${(P)1}"
osh: _gen/bin/oils_for_unix.mycpp.cc:48905: syntax_asdl::word_part_t* word_parse::WordParser::_ReadDoubleQuotedLeftParts(): Assertion `0' failed.
[1]    171786 IOT instruction (core dumped)  ./_bin/cxx-opt-sh/osh

interestingly it's ok without the double quotes i.e. it prints an error rather than crashing

osh-0.26.0$ echo ${(P)1}
  echo -n ${(P)1}
          ^~~~~
[ interactive ]:1: fatal: ZSH var subs are parsed, but can't be evaluated
@andychu
Copy link
Contributor

andychu commented Jan 20, 2025

Ah yes I can reproduce this -- the double quoted case has a bug, and should behave like the other code

Thanks for the report!

  File "/home/andy/git/oils-for-unix/oils/osh/word_parse.py", line 780, in _ReadDoubleQuotedLeftParts
    raise AssertionError(self.cur_token)
AssertionError: (Token
  id:Left_DollarBraceZsh
  length:5
  col:6
  line:(SourceLine line_num:1 content:"echo \"${(P)1}\"" src:(source.CFlag))
)


@andychu
Copy link
Contributor

andychu commented Jan 21, 2025

I just fixed this, it will be out with the next release

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants