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

IFS=: and : in literal word gives incorrect results #628

Open
xPMo opened this issue Mar 6, 2020 · 3 comments
Open

IFS=: and : in literal word gives incorrect results #628

xPMo opened this issue Mar 6, 2020 · 3 comments

Comments

@xPMo
Copy link

xPMo commented Mar 6, 2020

Input:

IFS=':'; word='a:'
printf '[%s] ' ${word}:b

Bash, Dash, etc:

[a] [:b]

Osh:

[a] [\] [b]

Input:

IFS=':'; word='a:'
printf '[%s] ' ${word}:

Bash, Dash, etc:

[a] [:]

Osh: (crashes, stderr)

Traceback (most recent call last):
  File "/home/pmo/Repos/oil/bin/oil.py", line 962, in <module>
    sys.exit(main(sys.argv))
  [...]
  File "/home/pmo/Repos/oil/osh/glob_.py", line 129, in GlobUnescape
    assert i != n - 1, 'Trailing backslash: %r' % s
AssertionError: Trailing backslash: '\\'
@andychu
Copy link
Contributor

andychu commented Mar 6, 2020

Doh, good catch. Yes it appears this is related to the IFS='\' bug I mentioned on #627 and that's exposed by the spec tests.

This makes fixing that a higher priority (both bugs can be fixed at once), although it's a little hairy and I'm not sure exactly when.

Keep the bug reports coming in any case! I haven't gotten any "fundamental language" bugs in awhile, and it helps to catch them early.

@andychu andychu changed the title Osh: Word Splitting crash when globbing after splitting Mar 6, 2020
andychu pushed a commit that referenced this issue Mar 6, 2020
@andychu
Copy link
Contributor

andychu commented Mar 6, 2020

Hm I'm getting the crash in both cases, with ${word}: and ${word}:b. I haven't gotten:

[a] [\] [b]

I'm not sure how important it is, but what version of OSH can you reproduce that with?


In any case I'm pretty sure I know how to fix it, but it's a bit hairy. I have to carry along some booleans further through the word expansion pipeline.

@xPMo
Copy link
Author

xPMo commented Mar 7, 2020

I can't reproduce it anymore, which is bizarre.

@andychu andychu mentioned this issue Apr 15, 2020
5 tasks
@andychu andychu changed the title crash when globbing after splitting IFS=: and : in literal word gives incorrect results Apr 15, 2020
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